ENH Take advantage of auto-scaffolded form fields (#581)

This commit is contained in:
Guy Sartorelli 2024-06-27 11:02:50 +12:00 committed by GitHub
parent ec2bc71541
commit d1acb202a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,6 +35,7 @@ use SilverStripe\Subsites\State\SubsiteState;
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 @@ class Subsite extends DataObject
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