Skip to content

Commit

Permalink
FIX Hide subsite operations when no subsites exist
Browse files Browse the repository at this point in the history
  • Loading branch information
raissanorth committed Feb 1, 2018
1 parent 5404daf commit 34c0c49
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Extensions/SiteTreeSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ public function updateCMSFields(FieldList $fields)
$subsitesMap = [];
if ($subsites && $subsites->count()) {
$subsitesToMap = $subsites->exclude('ID', $this->owner->SubsiteID);
$subsitesMap = $subsitesToMap->map('ID', 'Title')->toArray();
$subsitesMap = $subsitesToMap->map('ID', 'Title');
}

// Master page edit field (only allowed from default subsite to avoid inconsistent relationships)
$isDefaultSubsite = $this->owner->SubsiteID == 0 || $this->owner->Subsite()->DefaultSite;

if ($isDefaultSubsite && $subsitesMap) {
if ($isDefaultSubsite && $subsitesMap->count()) {
$fields->addFieldToTab(
'Root.Main',
ToggleCompositeField::create(
Expand All @@ -124,8 +124,7 @@ public function updateCMSFields(FieldList $fields)
DropdownField::create('CopyToSubsiteID', _t(
__CLASS__ . '.CopyToSubsite',
'Copy page to subsite'
), $subsitesMap)
->setEmptyString('Select an Option'),
), $subsitesMap),
CheckboxField::create(
'CopyToSubsiteWithChildren',
_t(__CLASS__ . '.CopyToSubsiteWithChildren', 'Include children pages?')
Expand Down

0 comments on commit 34c0c49

Please sign in to comment.