Jak utworzyć listę wyboru z wartościami z tabeli bazy danych w Symfony 2?Symfony 2 Formularz z listą wyboru
Mam 2 podmioty: Student i Classroom z relacji ManyToOne i muszę utworzyć formularz z polami folowing: nazwę, nazwisko, wiek, klasie (wybierz listę z dostępnych klas).
W moim Student Formularza mam
$builder
->add('name')
->add('surname')
->add('age')
->add('classroom', new ClassroomType())
;
W moim klasie Form mam to:
$classrooms =$this->getDoctrine()->getRepository('UdoCatalogBundle:Classroom')->findAll();
$builder
->add('clasa','choice',array('choices' => array($classrooms->getId() => $classrooms->getName())));
otrzymuję ten następujący błąd:
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
Kind Pozdrawiam, Cearnau Dan
tu wyjaśnienie: http://groups.google.com/group/symfony2/browse_thread/thread/ da8f72b33f9f93ba – tttony