From 191d93697dd2bc4122bd04965993914135bea55e Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Wed, 3 Oct 2018 16:50:48 +1300 Subject: [PATCH 1/2] Document new Search component in change logs. --- docs/en/04_Changelogs/4.3.0.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/en/04_Changelogs/4.3.0.md b/docs/en/04_Changelogs/4.3.0.md index 7068f2ead..b8f329c1f 100644 --- a/docs/en/04_Changelogs/4.3.0.md +++ b/docs/en/04_Changelogs/4.3.0.md @@ -5,6 +5,7 @@ - `DataList::column()` now returns all values and not just "distinct" values from a column as per the API docs - `DataList`, `ArrayList` and `UnsavedRalationList` all have `columnUnique()` method for fetching distinct column values - Take care with `stageChildren()` overrides. `Hierarchy::numChildren() ` results will only make use of `stageChildren()` customisations that are applied to the base class and don't include record-specific behaviour. + - New react-based search UI for the CMS, Asset-Admin, GridFields and ModelAdmins. ## Upgrading {#upgrading} @@ -12,3 +13,30 @@ Prior to this release `DataList` would erroneously return a distinct list of values from a column on an object. If this behaviour is still required, please use `columnUnique()` instead. + +### Using legacy GridField search API + +GridFields now default to using the new search UI which uses [SilverStripe's FormSchema API](https://api.silverstripe.org/master/SilverStripe/Forms/Schema/FormSchema.html). + +If you would rather continue using the old search API, you can remove the default `GridFieldFilterHeader` from your GridField configuration and replace with one whose _legacy_ flag has been enabled. + +To enable legacy mod on a `GridFieldFilterHeader`, just pass `true` to the first argument of its constructor. + +```php +public function getCMSFields() +{ + $fields = parent::getCMSFields(); + + // Configure grid field to use legacy search API + $legacySearchApiFlag = true; + $config = new GridFieldConfig_RecordEditor(); + $config->removeComponentsByType(GridFieldFilterHeader::class); + $config->addComponent(new GridFieldFilterHeader($legacySearchApiFlag)); + + $grid = new GridField('Companies', 'Companies', new DataList(Company::class), $config); + $fields->addFieldToTab('Root.Compagnu', $grid); + + return $fields; +} + +``` From 14a8707bf25e516aa8a7c22bc98cba52cc1b57f0 Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Thu, 4 Oct 2018 13:35:48 +1300 Subject: [PATCH 2/2] Address PR feedback for Search changelog --- docs/en/04_Changelogs/4.3.0.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/en/04_Changelogs/4.3.0.md b/docs/en/04_Changelogs/4.3.0.md index b8f329c1f..5daef0f32 100644 --- a/docs/en/04_Changelogs/4.3.0.md +++ b/docs/en/04_Changelogs/4.3.0.md @@ -5,7 +5,7 @@ - `DataList::column()` now returns all values and not just "distinct" values from a column as per the API docs - `DataList`, `ArrayList` and `UnsavedRalationList` all have `columnUnique()` method for fetching distinct column values - Take care with `stageChildren()` overrides. `Hierarchy::numChildren() ` results will only make use of `stageChildren()` customisations that are applied to the base class and don't include record-specific behaviour. - - New react-based search UI for the CMS, Asset-Admin, GridFields and ModelAdmins. + - New React-based search UI for the CMS, Asset-Admin, GridFields and ModelAdmins. ## Upgrading {#upgrading} @@ -16,11 +16,13 @@ If this behaviour is still required, please use `columnUnique()` instead. ### Using legacy GridField search API -GridFields now default to using the new search UI which uses [SilverStripe's FormSchema API](https://api.silverstripe.org/master/SilverStripe/Forms/Schema/FormSchema.html). +GridFields now default to using the new search UI which uses [SilverStripe's FormSchema API](api:SilverStripe\Forms\Schema\FormSchema). If you would rather continue using the old search API, you can remove the default `GridFieldFilterHeader` from your GridField configuration and replace with one whose _legacy_ flag has been enabled. -To enable legacy mod on a `GridFieldFilterHeader`, just pass `true` to the first argument of its constructor. +To enable the legacy search API on a `GridFieldFilterHeader`, you can either: +* set the `useLegacyFilterHeader` property to `true`, +* or pass `true` to the first argument of its constructor. ```php public function getCMSFields() @@ -28,13 +30,11 @@ public function getCMSFields() $fields = parent::getCMSFields(); // Configure grid field to use legacy search API - $legacySearchApiFlag = true; $config = new GridFieldConfig_RecordEditor(); - $config->removeComponentsByType(GridFieldFilterHeader::class); - $config->addComponent(new GridFieldFilterHeader($legacySearchApiFlag)); + $config->getComponentsByType(GridFieldFilterHeader::class)->useLegacyFilterHeader = true; - $grid = new GridField('Companies', 'Companies', new DataList(Company::class), $config); - $fields->addFieldToTab('Root.Compagnu', $grid); + $grid = GridField::create('Companies', 'Companies', DataList::create(Company::class), $config); + $fields->addFieldToTab('Root.Company', $grid); return $fields; }