Example:
~~~
echo Html::radioButtonGroup('rdo', [1], [1 => 'Option 1', 2 => 'Option 2', 3 => 'Option 3']);
~~~
public static radioButtonGroup ( string $name, string | array $selection = null, array $items = [], array $options = [] ) : string | ||
$name | string | the name attribute of each radio. |
$selection | string | array | the selected value(s). |
$items | array | the data item used to generate the radios. The array keys are the radio values, while the array values are the corresponding labels. |
$options | array | options (name => config) for the radio list container tag. The following options are specially handled: - `tag`: _string_, the tag name of the container element. - `unselect`: _string_, the value that should be submitted when none of the radio buttons is selected. By setting this option, a hidden input will be generated. - `encode`: boolean, whether to HTML-encode the radio button labels. Defaults to `true`. This option is ignored if `item` option is set. - `separator`: _string_, the HTML code that separates items. - `itemOptions`: _array_, the options for generating the radio button tag using [[radio()]]. - `item`: _Closure_, a callback that can be used to customize the generation of the HTML code corresponding to a single item in $items. The signature of this callback must be: ~~~ function ($index, $label, $name, $checked, $value) ~~~ where `$index` is the zero-based index of the radio button in the whole list; `$label` is the label for the radio button; and `$name`, `$value` and `$checked` represent the name, value and the checked status of the radio button input. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
리턴 | string | the generated radio button group |