diff --git a/src/Forms/GridField/GridFieldFilterHeader.php b/src/Forms/GridField/GridFieldFilterHeader.php index b70c28ec3..207c3f633 100755 --- a/src/Forms/GridField/GridFieldFilterHeader.php +++ b/src/Forms/GridField/GridFieldFilterHeader.php @@ -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');