Skip to content

Commit

Permalink
Fix Duplicate to Subsite functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
Garion Herman committed Jun 4, 2017
1 parent c248436 commit 1975861
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions code/extensions/LeftAndMainSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,11 @@ public function onAfterSave($record)

/**
* @param array $data
* @param Form $form
*/
public function copytosubsite($data, $form)
public function copytosubsite($data)
{
$page = DataObject::get_by_id(SiteTree::class, $data['ID']);
$subsite = DataObject::get_by_id('Subsite', $data['CopyToSubsiteID']);
$page = SiteTree::get()->byID($data['ID']);
$subsite = Subsite::get()->byID($data['CopyToSubsiteID']);
$includeChildren = isset($data['CopyToSubsiteWithChildren']) ? $data['CopyToSubsiteWithChildren'] : false;

$newPage = $page->duplicateToSubsite($subsite->ID, $includeChildren);
Expand Down
6 changes: 3 additions & 3 deletions code/extensions/SiteTreeSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\InlineFormAction;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\ToggleCompositeField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
Expand Down Expand Up @@ -109,7 +109,7 @@ public function updateCMSFields(FieldList $fields)
$isDefaultSubsite = $this->owner->SubsiteID == 0 || $this->owner->Subsite()->DefaultSite;

if ($isDefaultSubsite && $subsitesMap) {
$fields->addFieldsToTab(
$fields->addFieldToTab(
'Root.Main',
ToggleCompositeField::create('SubsiteOperations',
_t('SiteTreeSubsites.SubsiteOperations', 'Subsite Operations'),
Expand All @@ -118,7 +118,7 @@ public function updateCMSFields(FieldList $fields)
'Copy page to subsite'), $subsitesMap),
new CheckboxField('CopyToSubsiteWithChildren',
_t('SiteTreeSubsites.CopyToSubsiteWithChildren', 'Include children pages?')),
$copyAction = new InlineFormAction(
$copyAction = new FormAction(
'copytosubsite',
_t('SiteTreeSubsites.CopyAction', 'Copy')
)
Expand Down

0 comments on commit 1975861

Please sign in to comment.