Merge pull request #611 from xini/fix-multioptionfields

fix default values for EditableMultipleOptionField subclasses, fixes #610
This commit is contained in:
Robbie Averill 2017-06-13 12:29:52 +12:00 committed by GitHub
commit fe98baf75e
4 changed files with 8 additions and 4 deletions

View File

@ -22,7 +22,7 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField
// Set the default checked items // Set the default checked items
$defaultCheckedItems = $this->getDefaultOptions(); $defaultCheckedItems = $this->getDefaultOptions();
if ($defaultCheckedItems->count()) { if ($defaultCheckedItems->count()) {
$field->setDefaultItems($defaultCheckedItems->map('EscapedTitle')->keys()); $field->setDefaultItems($defaultCheckedItems->map('Value')->keys());
} }
$this->doUpdateFormField($field); $this->doUpdateFormField($field);

View File

@ -38,7 +38,7 @@ class EditableDropdown extends EditableMultipleOptionField
// Set default // Set default
$defaultOption = $this->getDefaultOptions()->first(); $defaultOption = $this->getDefaultOptions()->first();
if ($defaultOption) { if ($defaultOption) {
$field->setValue($defaultOption->EscapedTitle); $field->setValue($defaultOption->Value);
} }
$this->doUpdateFormField($field); $this->doUpdateFormField($field);
return $field; return $field;

View File

@ -75,6 +75,10 @@ class EditableOption extends DataObject
return $this->canEdit($member); return $this->canEdit($member);
} }
/**
* @deprecated 5.0 Use "$Title.XML" in templates instead
* @return string
*/
public function getEscapedTitle() public function getEscapedTitle()
{ {
return Convert::raw2att($this->Title); return Convert::raw2att($this->Title);

View File

@ -34,7 +34,7 @@ class EditableRadioField extends EditableMultipleOptionField
// Set default item // Set default item
$defaultOption = $this->getDefaultOptions()->first(); $defaultOption = $this->getDefaultOptions()->first();
if ($defaultOption) { if ($defaultOption) {
$field->setValue($defaultOption->EscapedTitle); $field->setValue($defaultOption->Value);
} }
$this->doUpdateFormField($field); $this->doUpdateFormField($field);
return $field; return $field;