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
|
||||
*/
|
||||
public function AddForm() {
|
||||
$record = $this->currentPage();
|
||||
|
||||
function AddForm() {
|
||||
$pageTypes = array();
|
||||
foreach($this->PageTypes() as $type) {
|
||||
$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');
|
||||
|
||||
$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
|
||||
$hintsField = new LiteralField(
|
||||
'Hints',
|
||||
@ -76,17 +73,20 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// TODO Re-enable search once it allows for HTML title display,
|
||||
// see http://open.silverstripe.org/ticket/7455
|
||||
// $parentField->setShowSearch(true);
|
||||
$parentModeField->setValue($this->request->getVar('ParentID') ? 'child' : 'top');
|
||||
|
||||
$parentModeField->addExtraClass('parent-mode');
|
||||
|
||||
// CMSMain->currentPageID() automatically sets the homepage,
|
||||
// which we need to counteract in the default selection (which should default to root, ID=0)
|
||||
$homepageSegment = RootURLController::get_homepage_link();
|
||||
if($record && $record->URLSegment != $homepageSegment) {
|
||||
$parentField->setValue($record->ID);
|
||||
if($parentID = $this->request->getVar('ParentID')) {
|
||||
$parentModeField->setValue('child');
|
||||
$parentField->setValue((int)$parentID);
|
||||
} else {
|
||||
$parentModeField->setValue('top');
|
||||
}
|
||||
|
||||
$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->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
||||
|
||||
if($parentID = $this->request->getVar('ParentID')) {
|
||||
$form->Fields()->dataFieldByName('ParentID')->setValue((int)$parentID);
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user