I am using SonataAdminBundle and I have a question about filters in the MyEntityAdmin class.
I have the first function protected function configureFormFields(FormMapper $formMapper)to list all the fields that will be displayed when creating / editing 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 protected function configureDatagridFilters(DatagridMapper $datagridMapper)for the protected function configureDatagridFilters(DatagridMapper $datagridMapper)fields in the filter forms, and I have to do the same, a user request for the field type of the object, but if I do the same, I have an error:
No attached service to type named 'entity'
How can i do this?
source
share