@(field: play.api.data.Field, options: Seq[(String, String)], args: Map[Symbol, Any])(implicit handler: helper.FieldConstructor, lang: Lang)

@import play.api.templates.PlayMagic.toHtmlArgs

@helper.input(field, args.toSeq:_*) { (id, name, value, htmlArgs) =>

    @for(v <- options) {
        <label for="@{id+"_"+v._1}" class="form-radio selectable">
            <input type="radio"
                   id="@{id+"_"+v._1}"
                   name="@name"
                   @if(value == None) {
                        @* Nothing previously selected so just select the default option. The default option is stored against the 'value key in the args map *@
                        value="@v._1" @(if(args.get('value) == Some(v._1)) "checked" else "")
                   } else {
                        @* Handle re-selecting the option in the widget that was chosen the last time the widget was displayed in a page *@
                        value="@v._1" @(if(value == Some(v._1)) "checked" else "")
                   }
                   @if(v == options.head) {@toHtmlArgs(htmlArgs)} else {@toHtmlArgs(htmlArgs - 'autofocus) }

            >
                   <span class="text">@v._2</span>
        </label>
    }
}
