fix default values for EditableMultipleOptionField subclasses

This commit is contained in:
Florian Thoma 2017-06-08 21:01:55 +10:00
parent 802c750a77
commit 6e69972c35
4 changed files with 9 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('EscapedValue')->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->EscapedValue);
} }
$this->doUpdateFormField($field); $this->doUpdateFormField($field);
return $field; return $field;

View File

@ -80,7 +80,12 @@ class EditableOption extends DataObject
return Convert::raw2att($this->Title); return Convert::raw2att($this->Title);
} }
/** public function getEscapedValue()
{
return Convert::raw2att($this->Value);
}
/**
* @param Member $member * @param Member $member
* @return bool * @return bool
*/ */

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->EscapedValue);
} }
$this->doUpdateFormField($field); $this->doUpdateFormField($field);
return $field; return $field;