두 개의 엔티티 인 이벤트와 도시가 있습니다. 그리고 이벤트 양식 만들기를 구현하고 싶습니다. 필드 중 하나는 데이터베이스 (도시 엔티티)의 값이있는 드롭 다운 목록이어야합니다. 내가 오류가symfony2 doctrine 드롭 다운 메뉴 관련된 엔티티의 선택 항목을 선택하십시오.
$city = $this->getDoctrine()
->getRepository('AtotrukisMainBundle:City')
->findBy(
array(),
array('priority' => 'ASC', 'name' => 'ASC')
);
$event = new Event();
$form = $this->createFormBuilder($event)
->add('name', 'text')
->add('description', 'textarea')
->add('startDate', 'datetime')
->add('endDate', 'datetime')
->add('map', 'text')
->add('city', 'choice', array(
'choice_list' => new ChoiceList($city->getId(), $city->getName())
))
->add('save', 'submit', array('label' => 'Sukurti'))
->getForm();
$form->handleRequest($request);
하지만 그와 함께 : 어쨌든 Error: Call to a member function getId() on array in /var/www/src/Atotrukis/MainBundle/Controller/EventController.php line 31
? 왜냐하면 내가 보았 듯이 이것은 교리 관리자가 반환 한 일련의 결과입니다. – Nevertheless