yii\helpers\BaseHtml::radio PHP Метод

radio() публичный статический Метод

Generates a radio button input.
public static radio ( string $name, boolean $checked = false, array $options = [] ) : string
$name string the name attribute.
$checked boolean whether the radio button should be checked.
$options array the tag options in terms of name-value pairs. See [[booleanInput()]] for details about accepted attributes.
Результат string the generated radio button tag
    public static function radio($name, $checked = false, $options = [])
    {
        return static::booleanInput('radio', $name, $checked, $options);
    }

Usage Example

Пример #1
0
 /**
  * @inheritDoc
  */
 public static function radio($name, $checked = false, $options = [])
 {
     if (!isset($options['id'])) {
         $options['id'] = Widget::$autoIdPrefix . Widget::$counter++;
     }
     $content = parent::radio($name, $checked, array_merge($options, ['label' => null]));
     if (isset($options['label'])) {
         $label = $options['label'];
         $for = $options['id'];
         $labelOptions = isset($options['labelOptions']) ? $options['labelOptions'] : [];
         unset($options['label'], $options['labelOptions']);
         $content .= parent::label($label, $for, $labelOptions);
     }
     return $content;
 }