Skip to content

Commit

Permalink
Merge pull request #611 from xini/fix-multioptionfields
Browse files Browse the repository at this point in the history
fix default values for EditableMultipleOptionField subclasses, fixes #610
  • Loading branch information
robbieaverill authored Jun 13, 2017
2 parents 802c750 + 4b26692 commit fe98baf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getFormField()
// Set the default checked items
$defaultCheckedItems = $this->getDefaultOptions();
if ($defaultCheckedItems->count()) {
$field->setDefaultItems($defaultCheckedItems->map('EscapedTitle')->keys());
$field->setDefaultItems($defaultCheckedItems->map('Value')->keys());
}

$this->doUpdateFormField($field);
Expand Down
2 changes: 1 addition & 1 deletion code/model/editableformfields/EditableDropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getFormField()
// Set default
$defaultOption = $this->getDefaultOptions()->first();
if ($defaultOption) {
$field->setValue($defaultOption->EscapedTitle);
$field->setValue($defaultOption->Value);
}
$this->doUpdateFormField($field);
return $field;
Expand Down
6 changes: 5 additions & 1 deletion code/model/editableformfields/EditableOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@ public function canDelete($member = null)
return $this->canEdit($member);
}

/**
* @deprecated 5.0 Use "$Title.XML" in templates instead
* @return string
*/
public function getEscapedTitle()
{
return Convert::raw2att($this->Title);
}

/**
/**
* @param Member $member
* @return bool
*/
Expand Down
2 changes: 1 addition & 1 deletion code/model/editableformfields/EditableRadioField.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getFormField()
// Set default item
$defaultOption = $this->getDefaultOptions()->first();
if ($defaultOption) {
$field->setValue($defaultOption->EscapedTitle);
$field->setValue($defaultOption->Value);
}
$this->doUpdateFormField($field);
return $field;
Expand Down

0 comments on commit fe98baf

Please sign in to comment.