According to sonata admin's documentation they have mentioned that global search module will search for all visible admins i.e show_in_dashboard
is set to true, and it will search in only those fields which are in configured admin's configureDatagridFilters()
function only,So the fields added to $datagridMapper
object of admin class will be searched in Sonata admin's global search.
For example you have news admin and in configureListFields()
you have 3 fields
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('id')
->add('name')
->add('createdDate');
}
And in configureDatagridFilters()
you have only name field to filter results
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper->add('name');
}
So Sonata will search in only name field of your news admin because you have configured a filter for this admin,So this filter is also used in global search for admin and no other field will be searched except name field
According to docs
The "global search" allows the end user to iterate over all visible
admins in the dashboard and search for the keyword. The current
implementation is very simple, every filter related to a string will
be searchable by default.
ADMIN BUNDLE ~ GLOBAL SEARCH
Other information regarding sonata global search is
The search iterates over admin classes and look for filter with the
option global_search set to true. If you are using the
SonataDoctrineORMBundle any text filter will be set to true by
default.
By default sonata looks for field description if set to string it automatically involves in global search you can also force field to be used in search by setting field option in $datagridMapper
's add()
like below
->add('name', null, array('global_search' => true), null, array()
Sonata Search