Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUG Prevent overwriting of draft/live preview form fields

By renaming fields to "StageLink" and "LiveLink",
which means they don't get influenced by the model getters
on Form->loadDataFrom(). Its also a more accurate
name for the field value, since it contains a full (nested) URL
rather than just a segment. Only used internally, so no API change.
  • Loading branch information...
commit 62783c75a9568b0c22d504d145b3aa9d1f5995b3 1 parent 11b85e9
@chillu chillu authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 code/controllers/CMSMain.php
View
10 code/controllers/CMSMain.php
@@ -574,17 +574,18 @@ public function getEditForm($id = null, $fields = null) {
$fields->push($idField = new HiddenField("ID", false, $id));
// Necessary for different subsites
$fields->push($liveURLField = new HiddenField("AbsoluteLink", false, $record->AbsoluteLink()));
- $fields->push($liveURLField = new HiddenField("LiveURLSegment"));
- $fields->push($stageURLField = new HiddenField("StageURLSegment"));
+ $fields->push($liveURLField = new HiddenField("LiveLink"));
+ $fields->push($stageURLField = new HiddenField("StageLink"));
$fields->push(new HiddenField("TreeTitle", false, $record->TreeTitle));
$fields->push(new HiddenField('Sort','', $record->Sort));
if($record->ID && is_numeric( $record->ID ) ) {
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = $record->ID");
- if($liveRecord) $liveURLField->setValue($liveRecord->AbsoluteLink());
+ if($liveRecord) {
+ $liveURLField->setValue(Controller::join_links($liveRecord->AbsoluteLink(), '?stage=Live'));
+ }
}
-
if(!$deletedFromStage) {
$stageURLField->setValue(Controller::join_links($record->AbsoluteLink(), '?stage=Stage'));
}
@@ -615,7 +616,6 @@ public function getEditForm($id = null, $fields = null) {
$form = new Form($this, "EditForm", $fields, $actions, $validator);
$form->loadDataFrom($record);
- $stageURLField->setValue(Controller::join_links($record->getStageURLSegment(), '?stage=Stage'));
$form->disableDefaultAction();
$form->addExtraClass('cms-edit-form');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
Please sign in to comment.
Something went wrong with that request. Please try again.