I'm trying to use the entityToIdTransformer in a form so I can populate a choiceField dynamically.
Here's my code. namespace Sensio\HelloBundle\Form; use Symfony\Component\Form\Form; use Symfony\Bundle\DoctrineBundle\Form\ValueTransformer\EntityToIDTransformer; use Symfony\Component\Form\ChoiceField; class JobForm extends Form { public function __construct() { $em = $this->get('doctrine.orm.entity_manager'); } public function configure() { $em = $this->get('doctrine.orm.entity_manager'); $userChoices = array(); $users = $em->getRepository('Sensio\HelloBundle\Entity\User')->findAll(); foreach ($users as $user) { $userChoices[$user->getId()] = $user->getName(); } $userTransformer = new EntityToIDTransformer(array( 'em' => $em, 'className' => 'User', )); $this->add(new ChoiceField('engineer', array( 'choices' => $userChoices, 'value_transformer' => $userTransformer, ))); } } I get the error Field "doctrine.orm.entity_manager" does not exist. -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en