Symfony 2에서 데이터베이스 테이블의 값으로 선택 목록을 만들려면 어떻게해야합니까?Symfony 2 선택 목록이있는 양식
나는 두 기관이 있습니다 학생과 ManyToOne 관계와 교실을하고 나는 folowing 필드가있는 양식을 작성해야합니다 : 목록을 선택 (이름, 성, 나이, 교실을 사용 가능한 클래스에서). 내 학생 양식에서
내가 가진 내 교실 양식에서
$builder
->add('name')
->add('surname')
->add('age')
->add('classroom', new ClassroomType())
;
나는이 있습니다
$classrooms =$this->getDoctrine()->getRepository('UdoCatalogBundle:Classroom')->findAll();
$builder
->add('clasa','choice',array('choices' => array($classrooms->getId() => $classrooms->getName())));
나는이 다음과 같은 오류 얻을 :
Fatal error: Call to undefined method Udo\CatalogBundle\Form\ClassroomType::getDoctrine() in /var/www/html/pos/src/Udo/CatalogBundle/Form/ClassroomType.php on line 13
종류를 감사합니다, Cearnau Dan
설명입니다 http://groups.google.com/group/symfony2/browse_thread/thread/ da8f72b33f9f93ba – tttony