Sha256: 552d242188ce3e33f9c9e3ea4625e8ef7206c18e43886e44a23f64913d40b93b

Contents?: true

Size: 1.47 KB

Versions: 12

Compression:

Stored size: 1.47 KB

Contents

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|
            value, id = (row.is_a?(Array) ? row : [row, row])
            if @object
              checked = @object.send(method) == id
            else
              checked = options[:value] == id
            end
            if buttonset
              template.concat(radio_button(method, id, options.merge(:checked => checked)))
              template.concat(label(name_to_id("#{method}_#{id}"), value, label_options))
            else
              template.concat(column do
                template.concat(label(name_to_id("#{method}_#{id}"), value, label_options))
                template.concat(radio_button(method, id, options.merge(:checked => checked)))
              end)
            end
          end
        end
      end
      
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
jquery-ui-form-0.2.6 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.2.5 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.2.4 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.2.3 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.2.2 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.2.1 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.2.0 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.1.6 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.1.5 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.1.4 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.1.3 lib/jquery_ui_form/inputs/radio_input.rb
jquery-ui-form-0.1.2 lib/jquery_ui_form/inputs/radio_input.rb