silverstripe-userforms/code/model/editableformfields/EditableRadioField.php
Damian Mooyman 9f112e3b23 Add "Add page break" button
Fix unit test failures
2015-08-11 14:18:46 +12:00

39 lines
781 B
PHP
Executable File

<?php
/**
* EditableRadioField
*
* Represents a set of selectable radio buttons
*
* @package userforms
*/
class EditableRadioField extends EditableMultipleOptionField {
private static $singular_name = 'Radio field';
private static $plural_name = 'Radio fields';
/**
* @return FieldList
*/
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeByName('Default');
return $fields;
}
public function getFormField() {
$field = OptionsetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap());
// Set default item
$defaultOption = $this->getDefaultOptions()->first();
if($defaultOption) {
$field->setValue($defaultOption->EscapedTitle);
}
$this->doUpdateFormField($field);
return $field;
}
}