Skip to content

Commit

Permalink
FIX Update CMS fields now that they're being scaffolded
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Aug 8, 2024
1 parent c2e071c commit b4bebb5
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/RegistryPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Control\Controller;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\NumericField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataList;
Expand Down Expand Up @@ -75,16 +76,16 @@ public function getPageLength()

public function getCMSFields()
{
$fields = parent::getCMSFields();
$classDropdown = DropdownField::create('DataClass', $this->fieldLabel('DataClass'), $this->getDataClasses());
$classDropdown->setEmptyString(_t(__CLASS__ . '.SelectDropdownDefault', 'Select one'));
$fields->addFieldToTab('Root.Main', $classDropdown, 'Content');
$fields->addFieldToTab(
'Root.Main',
NumericField::create('PageLength', $this->fieldLabel('PageLength')),
'Content'
);
return $fields;
$this->beforeUpdateCMSFields(function (FieldList $fields) {
$classDropdown = DropdownField::create(
'DataClass',
$this->fieldLabel('DataClass'),
$this->getDataClasses()
);
$classDropdown->setEmptyString(_t(__CLASS__ . '.SelectDropdownDefault', 'Select one'));
$fields->replaceField('DataClass', $classDropdown);
});
return parent::getCMSFields();
}

public function LastUpdated()
Expand Down

0 comments on commit b4bebb5

Please sign in to comment.