mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX support search filter instances (#9991)
and also fully qualified class names
This commit is contained in:
parent
d1d1e9f58e
commit
0cfd98d87a
@ -15,6 +15,7 @@ use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use LogicException;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
|
||||
/**
|
||||
* This class is is responsible for adding objects to another object's has_many
|
||||
@ -349,7 +350,18 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
||||
if (!$customSearchableFields || array_search($name, $customSearchableFields)) {
|
||||
$filter = 'StartsWith';
|
||||
} else {
|
||||
$filter = preg_replace('/Filter$/', '', $spec['filter']);
|
||||
$filterName = $spec['filter'];
|
||||
// It can be an instance
|
||||
if ($filterName instanceof SearchFilter) {
|
||||
$filterName = get_class($filterName);
|
||||
}
|
||||
// It can be a fully qualified class name
|
||||
if (strpos($filterName, '\\') !== false) {
|
||||
$filterNameParts = explode("\\", $filterName);
|
||||
// We expect an alias matching the class name without namespace, see #coresearchaliases
|
||||
$filterName = array_pop($filterNameParts);
|
||||
}
|
||||
$filter = preg_replace('/Filter$/', '', $filterName);
|
||||
}
|
||||
$fields[] = "{$name}:{$filter}";
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user