Generates an HTML object.
public radio ( string $name, array $options = [] ) : string | ||
$name | string | The name of the field |
$options | array | All options to be used when generating the radio `` element: - `'checked'` _boolean_: Whether or not the field should be selected by default. - `'value'` _mixed_: if specified, it will be used as the 'value' html attribute. Defaults to `1` - Any other options specified are rendered as HTML attributes of the element. |
Résultat | string | Returns a `` tag with the given name and attributes |
public function radio($name, array $options = array(), array $list = array()) { if (empty($list)) { if (!isset($options['checked']) && isset($options['value'])) { $value = false; if ($name && $this->_binding ) { $value = $this->_binding->data($name); } if ($options['value'] == $value) $options['checked'] = true; } return parent::radio($name,$options); } $out = ''; foreach ($list as $value => $label) { $itemOptions = $options; $itemOptions['id'] = $name.'-'.$label; $itemOptions['value'] = $value; $out .= '<div class="radio">'; $out .= $this->radio($name, $itemOptions, array()); $out .= $this->label($itemOptions['id'], $label); $out .= '</div>'; } return $out; }