mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUGFIX: Only rely on request var ParentID, instead of using both $this->currentPage() and the request var. This will hopefully fix issues around the parent ID getting lost.
This commit is contained in:
parent
98e824bced
commit
6b6571cd28
@ -15,9 +15,7 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
/**
|
/**
|
||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
public function AddForm() {
|
function AddForm() {
|
||||||
$record = $this->currentPage();
|
|
||||||
|
|
||||||
$pageTypes = array();
|
$pageTypes = array();
|
||||||
foreach($this->PageTypes() as $type) {
|
foreach($this->PageTypes() as $type) {
|
||||||
$html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>',
|
$html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>',
|
||||||
@ -39,7 +37,6 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
$childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page');
|
$childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page');
|
||||||
|
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
// new HiddenField("ParentID", false, ($this->parentRecord) ? $this->parentRecord->ID : null),
|
|
||||||
// TODO Should be part of the form attribute, but not possible in current form API
|
// TODO Should be part of the form attribute, but not possible in current form API
|
||||||
$hintsField = new LiteralField(
|
$hintsField = new LiteralField(
|
||||||
'Hints',
|
'Hints',
|
||||||
@ -72,21 +69,24 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
_t(
|
_t(
|
||||||
'CMSMain.AddPageRestriction',
|
'CMSMain.AddPageRestriction',
|
||||||
'Note: Some page types are not allowed for this selection'
|
'Note: Some page types are not allowed for this selection'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO Re-enable search once it allows for HTML title display,
|
// TODO Re-enable search once it allows for HTML title display,
|
||||||
// see http://open.silverstripe.org/ticket/7455
|
// see http://open.silverstripe.org/ticket/7455
|
||||||
// $parentField->setShowSearch(true);
|
// $parentField->setShowSearch(true);
|
||||||
$parentModeField->setValue($this->request->getVar('ParentID') ? 'child' : 'top');
|
|
||||||
$parentModeField->addExtraClass('parent-mode');
|
$parentModeField->addExtraClass('parent-mode');
|
||||||
|
|
||||||
// CMSMain->currentPageID() automatically sets the homepage,
|
// CMSMain->currentPageID() automatically sets the homepage,
|
||||||
// which we need to counteract in the default selection (which should default to root, ID=0)
|
// which we need to counteract in the default selection (which should default to root, ID=0)
|
||||||
$homepageSegment = RootURLController::get_homepage_link();
|
if($parentID = $this->request->getVar('ParentID')) {
|
||||||
if($record && $record->URLSegment != $homepageSegment) {
|
$parentModeField->setValue('child');
|
||||||
$parentField->setValue($record->ID);
|
$parentField->setValue((int)$parentID);
|
||||||
|
} else {
|
||||||
|
$parentModeField->setValue('top');
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
@ -102,10 +102,6 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
$form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses());
|
$form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses());
|
||||||
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
||||||
|
|
||||||
if($parentID = $this->request->getVar('ParentID')) {
|
|
||||||
$form->Fields()->dataFieldByName('ParentID')->setValue((int)$parentID);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user