Skip to content
This repository
Browse code

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
Ingo Schommer authored August 27, 2012

Showing 1 changed file with 5 additions and 5 deletions. Show diff stats Hide diff stats

  1. 10  code/controllers/CMSMain.php
10  code/controllers/CMSMain.php
@@ -574,17 +574,18 @@ public function getEditForm($id = null, $fields = null) {
574 574
 			$fields->push($idField = new HiddenField("ID", false, $id));
575 575
 			// Necessary for different subsites
576 576
 			$fields->push($liveURLField = new HiddenField("AbsoluteLink", false, $record->AbsoluteLink()));
577  
-			$fields->push($liveURLField = new HiddenField("LiveURLSegment"));
578  
-			$fields->push($stageURLField = new HiddenField("StageURLSegment"));
  577
+			$fields->push($liveURLField = new HiddenField("LiveLink"));
  578
+			$fields->push($stageURLField = new HiddenField("StageLink"));
579 579
 			$fields->push(new HiddenField("TreeTitle", false, $record->TreeTitle));
580 580
 
581 581
 			$fields->push(new HiddenField('Sort','', $record->Sort));
582 582
 
583 583
 			if($record->ID && is_numeric( $record->ID ) ) {
584 584
 				$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = $record->ID");
585  
-				if($liveRecord) $liveURLField->setValue($liveRecord->AbsoluteLink());
  585
+				if($liveRecord) {
  586
+					$liveURLField->setValue(Controller::join_links($liveRecord->AbsoluteLink(), '?stage=Live'));
  587
+				}
586 588
 			}
587  
-			
588 589
 			if(!$deletedFromStage) {
589 590
 				$stageURLField->setValue(Controller::join_links($record->AbsoluteLink(), '?stage=Stage'));
590 591
 			}
@@ -615,7 +616,6 @@ public function getEditForm($id = null, $fields = null) {
615 616
 			
616 617
 			$form = new Form($this, "EditForm", $fields, $actions, $validator);
617 618
 			$form->loadDataFrom($record);
618  
-			$stageURLField->setValue(Controller::join_links($record->getStageURLSegment(), '?stage=Stage'));
619 619
 			$form->disableDefaultAction();
620 620
 			$form->addExtraClass('cms-edit-form');
621 621
 			$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));

0 notes on commit 62783c7

Please sign in to comment.
Something went wrong with that request. Please try again.