# radio

## Purpose

Helper tag for a radio button

## Examples

    <g:radio name="myGroup" value="1"/>
    <g:radio name="myGroup" value="2" checked="true"/>

results in:

    <input type="radio" name="myGroup" value="1" />
    <input type="radio" name="myGroup" checked="checked" value="2" />

## Description

Attributes

- `value` (required) - The value of the radio button
- `name` (required) - The name of the radio button
- `checked` (optional) - boolean to indicate that the radio button should be checked

## Source

Show Source

    def radio = { attrs ->
            def value = attrs.remove('value')
            attrs.id = attrs.id ?: attrs.name
            def name = attrs.remove('name')
            def disabled = attrs.remove('disabled')
            if (disabled && Boolean.valueOf(disabled)) {
                attrs.disabled = 'disabled'
            }
            def checked = attrs.remove('checked') ? true : false
            out << "<input type=\"radio\" name=\"${name}\"${ checked ? ' checked="checked" ' : ' '}value=\"${value?.toString()?.encodeAsHTML()}\" "
            // process remaining attributes
            outputAttributes(attrs)        // close the tag, with no body
            out << ' />'
        }