Version: current

     1 <?php
     2 /**
     3  * EditableRadioField
     4  *
     5  * Represents a set of selectable radio buttons
     6  *
     7  * @package userforms
     8  */
     9
    10 class EditableRadioField extends EditableMultipleOptionField {
    11
    12     static $singular_name = 'Radio field';
    13
    14     static $plural_name = 'Radio fields';
    15
    16     public function getFieldConfiguration() {
    17         $options = parent::getFieldConfiguration();
    18         $options->removeByName("Fields[$this->ID][CustomSettings][Placeholder]");
    19         $options->push(new CheckboxField("Fields[$this->ID][CustomSettings][ArrangeInLine]", _t('EditableCheckboxGroupField.ArrangeInLine', 'Arrange in line?'), $this->getSetting('ArrangeInLine')));
    20
    21         return $options;
    22     }
    23
    24     function getFormField() {
    25         $optionSet = $this->Options();
    26         $options = array();
    27
    28         if($optionSet) {
    29             foreach( $optionSet as $option ) {
    30                 $options[$option->Title] = $option->Title;
    31             }
    32         }
    33         $field = new OptionsetField($this->Name, $this->Title, $options);
    34         if ($this->getSetting('ArrangeInLine')) {
    35             $field->addExtraClass('in_line');
    36         }
    37         return $field;
    38     }
    39
    40     function getArrangeInLine() {
    41         return $this->getSetting('ArrangeInLine');
    42     }
    43 }

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -