Skip to content

Commit

Permalink
BUGFIX Marking fields as readonly in CMSMain->compareversions() befor…
Browse files Browse the repository at this point in the history
…e loading data, to avoid loading invalid values (HTML diffs) into the fields (AIR-39)
  • Loading branch information
chillu committed Oct 7, 2011
1 parent 093eb6c commit f7d322a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions code/controllers/CMSPageHistoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,23 @@ function CompareVersionsForm($versionID, $otherVersionID) {
if($record) {
$form = $this->getEditForm($id, null, null, true);
$form->setActions(new FieldSet());
$form->loadDataFrom($record);
$form->addExtraClass('compare');

// Comparison views shouldn't be editable.
// Its important to convert fields *before* loading data,
// as the comparison output is HTML and not valid values for the various field types
$readonlyFields = $form->Fields()->makeReadonly();
$form->setFields($readonlyFields);

$form->loadDataFrom($record);
$form->loadDataFrom(array(
"ID" => $id,
"Version" => $fromVersion,
));

$form->addExtraClass('compare');
foreach($form->Fields()->dataFields() as $field) {
$field->dontEscape = true;
}

return $form;
}
Expand Down

0 comments on commit f7d322a

Please sign in to comment.