Código PHP:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder ->add('name', 'text', array(
'mapped' => true,
'label'=> 'Nombre',
'required' => true,
'attr' => array(
'class' => 'simple_field',
),
));
->add('usuarios', 'entity', array(
'mapped' => false,
'required' => true,
'empty_value' => 'Select',
'class' => 'AppBundle:User',
'property' => 'fullName',
'multiple' => true,
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('u')
->where('u.profile = :profile')
->setParameter('profile', 2)
->orderBy('u.fullName', 'ASC');
},
));
}