Cake\View\Helper\FormHelper::radio PHP Method

radio() public method

### Attributes: - value - Indicates the value when this radio button is checked. - label - boolean to indicate whether or not labels for widgets should be displayed. - hiddenField - boolean to indicate if you want the results of radio() to include a hidden input with a value of ''. This is useful for creating radio sets that are non-continuous. - disabled - Set to true or disabled to disable all the radio buttons. - empty - Set to true to create an input with the value '' as the first option. When true the radio label will be 'empty'. Set this option to a string to control the label value.
public radio ( string $fieldName, array | Traversable $options = [], array $attributes = [] ) : string
$fieldName string Name of a field, like this "modelname.fieldname"
$options array | Traversable Radio button options array.
$attributes array Array of attributes.
return string Completed radio widget set.
    public function radio($fieldName, $options = [], array $attributes = [])
    {
        $attributes['options'] = $options;
        $attributes['idPrefix'] = $this->_idPrefix;
        $attributes = $this->_initInputField($fieldName, $attributes);
        $hiddenField = isset($attributes['hiddenField']) ? $attributes['hiddenField'] : true;
        unset($attributes['hiddenField']);
        $radio = $this->widget('radio', $attributes);
        $hidden = '';
        if ($hiddenField) {
            $hidden = $this->hidden($fieldName, ['value' => '', 'form' => isset($attributes['form']) ? $attributes['form'] : null, 'name' => $attributes['name']]);
        }
        return $hidden . $radio;
    }