Closed aleksanderkakol closed 11 months ago
Is it possible to add the option to choose the filter type in the global search?
You're talking like all the filters are using the same filter type but it's not the case. What if the global search is using two stringFilter and one numberFilter.
Maybe something like https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Search/SearchHandler.php#L60
$defaultSearchType = $filter instanceof SomeNewInterface ? $filter->getSearchType() : null
$datagrid->setValue($formName, $defaultSearchType, $term);
with
public function getSearchType(): int
{
return $this->getOption('global_search_type');
}
and it will require to set
global_search => true,
global_search_type => ...::CONTAINS
Or maybe global_search could be a bool or a filter type
global_search => ...::CONTAINS
What if the global search is using two stringFilter and one numberFilter.
The global search currently uses only filters with SearchableFilterInterface, which is currently implemented only for stringFilter. https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Search/SearchHandler.php#L54
And the Uid filter too you mean https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/6f45c37d06c168827f1965cc00c3e8a0191f1fb5/src/Filter/UidFilter.php#L26 ?
And any custom filter every developer can implement on personal projects.
So my comment is still valid.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Is it possible to add the option to choose the filter type in the global search?
The current implementation sets the setValue in the datagrid to null, which results in the default usage of the StringFilter with the "Contains" filter
StringFilter.php
The type is hardcoded to null at all times:
SearchHandler.php