From 6dd0535442e8be41b3c10d67bbc96b966df23f37 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 5 Jan 2012 17:02:27 +0100 Subject: [PATCH] MINOR Only set current record in CMSMain->AddForm() if its not the homepage - not ideal, but root is the more likely default given the information at hand --- code/controllers/CMSMain.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 17bee34b..720373f0 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -1085,7 +1085,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr ) ); $parentField->setShowSearch(true); - $parentField->setValue(($record) ? $record->ID : null); + + // 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); + } $actions = new FieldList( // $resetAction = new ResetFormAction('doCancel', _t('CMSMain.Cancel', 'Cancel')),