mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
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.
This commit is contained in:
parent
11b85e988e
commit
62783c75a9
@ -574,17 +574,18 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$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 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
$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'));
|
||||
|
Loading…
Reference in New Issue
Block a user