module JqueryUiForm module Inputs module RadioInput def radio_input(method, options = {}) # radio_button(method, tag_value, options) legend, options = label_text(method, options) collection = options.delete(:collection) label_options = options.delete(:html_label) || {} label_options[:required] = options.delete(:required) buttonset = options.delete(:buttonset) || false fieldset_options = {} fieldset_options[:class] = "to-buttonset" if buttonset output = fieldset(legend.html_safe, fieldset_options) do template.concat(inline_hint(options.delete(:hint))) template.concat(inline_error(method)) collection.each do |row| if buttonset template.concat(radio_button(method, row[1], options.merge(:checked => @object.send(method) == row[1]))) template.concat(label(name_to_id("#{method}_#{row[1]}"), row[0], label_options)) else template.concat(column do template.concat(label(name_to_id("#{method}_#{row[1]}"), row[0], label_options)) template.concat(radio_button(method, row[1], options.merge(:checked => @object.send(method) == row[1]))) end) end end end end end end end