Anyone has any idea how to add some custom options to an entity field type in a nice and clean way? e.g
->add('groups', 'entity', array(
'class' => 'MyBundle:Groups',
'multiple' => 'true',
'query_builder' => function(GroupsRepository $er) {
return $er->createQueryBuilder('g')
->orderBy('g.name', 'ASC');
}))
Let’s say that query builder returns “Group1”, “Group2” and “Group3”. What I want is to “inject” another option called “Any Group” for example.
Thanks,Stelian
The
EntityTypeis a child of theChoiceType. So, you have access to the same options.