From a9e9d72850cf8fa2e8ba2d40667de2837a4a89b6 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Wed, 19 Jun 2024 13:26:44 +1200 Subject: [PATCH] ENH Take advantage of auto-scaffolded form fields --- src/Model/Subsite.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Model/Subsite.php b/src/Model/Subsite.php index 2f508897..6cb413c6 100644 --- a/src/Model/Subsite.php +++ b/src/Model/Subsite.php @@ -35,6 +35,7 @@ use SilverStripe\Versioned\Versioned; use UnexpectedValueException; use SilverStripe\Core\ClassInfo; +use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter; /** * A dynamically created subsite. SiteTree objects can now belong to a subsite. @@ -666,16 +667,10 @@ public function canEdit($member = false) public function getCMSFields() { $this->beforeUpdateCMSFields(function (FieldList $fields) { - if ($this->exists()) { - // Add a GridField for domains to a new tab if the subsite has already been created - $fields->addFieldsToTab('Root.Domains', [ - GridField::create( - 'Domains', - '', - $this->Domains(), - GridFieldConfig_RecordEditor::create(10) - ) - ]); + $domainsGridField = $fields->dataFieldByName('Domains'); + if ($domainsGridField instanceof GridField) { + $domainsGridField->setTitle(''); + $domainsGridField->getConfig()->removeComponentsByType(GridFieldAddExistingAutocompleter::class); } // Remove the default scaffolded blacklist field, we replace it with a checkbox set field