mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Prefixing search filters for the React search form context
This commit is contained in:
parent
c54e7317d2
commit
c503dbd634
@ -235,11 +235,19 @@ class GridFieldFilterHeader implements GridField_URLHandler, GridField_HTMLProvi
|
||||
|
||||
$name = $gridField->Title ?: singleton($gridField->getModelClass())->i18n_plural_name();
|
||||
|
||||
// Prefix "Search__" onto the filters for the React component
|
||||
$filters = $context->getSearchParams();
|
||||
if (!$this->useLegacyFilterHeader && !empty($filters)) {
|
||||
$filters = array_combine(array_map(function ($key) {
|
||||
return 'Search__' . $key;
|
||||
}, array_keys($filters)), $filters);
|
||||
}
|
||||
|
||||
$schema = [
|
||||
'formSchemaUrl' => $schemaUrl,
|
||||
'name' => $searchField,
|
||||
'placeholder' => _t(__CLASS__ . '.Search', 'Search "{name}"', ['name' => $name]),
|
||||
'filters' => $context->getSearchParams() ?: new \stdClass, // stdClass maps to empty json object '{}'
|
||||
'filters' => $filters ?: new \stdClass, // stdClass maps to empty json object '{}'
|
||||
'gridfield' => $gridField->getName(),
|
||||
'searchAction' => GridField_FormAction::create($gridField, 'filter', false, 'filter', null)->getAttribute('name'),
|
||||
'clearAction' => GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->getAttribute('name')
|
||||
@ -294,6 +302,7 @@ class GridFieldFilterHeader implements GridField_URLHandler, GridField_HTMLProvi
|
||||
$searchFields,
|
||||
new FieldList()
|
||||
);
|
||||
|
||||
$form->setFormMethod('get');
|
||||
$form->setFormAction($gridField->Link());
|
||||
$form->addExtraClass('cms-search-form form--no-dividers');
|
||||
|
Loading…
Reference in New Issue
Block a user