Call EntityManager inside a form
===

We can easily custom the powerful Synfony2 form component with an [entity Field Type][1]

    use Doctrine\ORM\EntityRepository;
    // ...
    
    $builder->add('users', 'entity', array(
        'class' => 'AcmeHelloBundle:User',
        'query_builder' => function(EntityRepository $er) {
            return $er->createQueryBuilder('u')
                ->orderBy('u.username', 'ASC');
        },
    ));

Is there a way to inject a method from the Entitymanager instead? I am thinking that in the case of long queries, it might be interesting to have the option to use custom methods from an EntityManager instead?

Thanks

  [1]: http://symfony.com/doc/current/reference/forms/types/entity.html