Skip to content

Commit

Permalink
ENH Take advantage of auto-scaffolded form fields (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Jun 26, 2024
1 parent ec2bc71 commit d1acb20
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Model/Subsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d1acb20

Please sign in to comment.