I'm using SonataAdminBundle and I have a question about filters in the class MyEntityAdmin.
I have a first function protected function configureFormFields(FormMapper $formMapper)
for list all fields to be shown on create/edit forms.
If I have a field type entity, I can do something like this:
->add('commercial', 'entity', array(
'class' => 'MyBundle:User',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('u')
->groupBy('u.id')
->orderBy('u.id', 'ASC')
->setParameters(array(1 => 'Commercial'));
},)
)
But I have another function protected function configureDatagridFilters(DatagridMapper $datagridMapper)
for Fields to be shown on filter forms, and I have do to the same thing, a custom query on an entity field type, but if I do the same, I have the error:
No attached service to type named `entity`
How can I do that ?