radio() public static method

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.
return string the generated radio button tag
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;
 }