Skip to content

Commit

Permalink
Merge pull request #128 from NightJar/patch-1
Browse files Browse the repository at this point in the history
Use FormFields in Injectable format
  • Loading branch information
GuySartorelli authored Oct 27, 2022
2 parents 5c65c24 + c069a8a commit c0cc051
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions code/SiteConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,20 @@ public function getCMSFields()
$viewAllGroupsMap = $mapFn(Permission::get_groups_by_permission(['SITETREE_VIEW_ALL', 'ADMIN']));
$editAllGroupsMap = $mapFn(Permission::get_groups_by_permission(['SITETREE_EDIT_ALL', 'ADMIN']));

$fields = new FieldList(
new TabSet(
$fields = FieldList::create(
TabSet::create(
"Root",
$tabMain = new Tab(
$tabMain = Tab::create(
'Main',
$titleField = new TextField("Title", _t(self::class . '.SITETITLE', "Site title")),
$taglineField = new TextField("Tagline", _t(self::class . '.SITETAGLINE', "Site Tagline/Slogan"))
$titleField = TextField::create("Title", _t(self::class . '.SITETITLE', "Site title")),
$taglineField = TextField::create(
"Tagline",
_t(self::class . '.SITETAGLINE', "Site Tagline/Slogan")
)
),
$tabAccess = new Tab(
$tabAccess = Tab::create(
'Access',
$viewersOptionsField = new OptionsetField(
$viewersOptionsField = OptionsetField::create(
"CanViewType",
_t(self::class . '.VIEWHEADER', "Who can view pages on this site?")
),
Expand All @@ -124,7 +127,7 @@ public function getCMSFields()
'data-placeholder',
_t('SilverStripe\\CMS\\Model\\SiteTree.GroupPlaceholder', 'Click to select group')
),
$editorsOptionsField = new OptionsetField(
$editorsOptionsField = OptionsetField::create(
"CanEditType",
_t(self::class . '.EDITHEADER', "Who can edit pages on this site?")
),
Expand All @@ -137,7 +140,7 @@ public function getCMSFields()
'data-placeholder',
_t('SilverStripe\\CMS\\Model\\SiteTree.GroupPlaceholder', 'Click to select group')
),
$topLevelCreatorsOptionsField = new OptionsetField(
$topLevelCreatorsOptionsField = OptionsetField::create(
"CanCreateTopLevelType",
_t(self::class . '.TOPLEVELCREATE', "Who can create pages in the root of the site?")
),
Expand All @@ -152,7 +155,7 @@ public function getCMSFields()
)
)
),
new HiddenField('ID')
HiddenField::create('ID')
);

$viewersOptionsSource = [];
Expand Down Expand Up @@ -238,14 +241,14 @@ public function getCMSFields()
public function getCMSActions()
{
if (Permission::check('ADMIN') || Permission::check('EDIT_SITECONFIG')) {
$actions = new FieldList(
$actions = FieldList::create(
FormAction::create(
'save_siteconfig',
_t('SilverStripe\\CMS\\Controllers\\CMSMain.SAVE', 'Save')
)->addExtraClass('btn-primary font-icon-save')
);
} else {
$actions = new FieldList();
$actions = FieldList::create();
}

$this->extend('updateCMSActions', $actions);
Expand Down

0 comments on commit c0cc051

Please sign in to comment.