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 |
}], 'updateOptions' => ['title' => Yii::t('app', 'View'), 'data-toggle' => 'tooltip'], 'deleteOptions' => ['title' => Yii::t('app', 'Delete'), 'data-toggle' => 'tooltip'], 'width' => '120px']]; ?> <div class="email-index"> <?php // Title $actionTypes = Email::actionTypes(); if (!Yii::$app->getModule('email')->enableSent) { unset($actionTypes[Email::ACTION_SENT]); } ?> <h1> <?php echo Html::encode($this->title); ?> : <?php echo Html::radioButtonGroup('actionType', Yii::$app->session->get('emails.actionType'), $actionTypes); ?> <?php // Buttons ?> <div class="navbar-right"> <?php if (Yii::$app->getModule('email')->enableTemplates || Yii::$app->user->can('Superadmin')) { ?> <?php echo Html::a('<i class="fa fa-file-text-o" aria-hidden="true"></i>', Url::toRoute(['/email/template']), ['class' => 'btn btn-default', 'data-pjax' => 0]); ?> <?php } ?>