module SimpleForm::ActionViewExtensions::Builder
def collection_radio(attribute, collection, value_method, text_method, options={}, html_options={})
item or an array of items.
* disabled => the value or values that should be disabled. Accepts a single
* checked => the value that should be checked initially.
Collection radio accepts some extra options:
== Options
end
f.collection_radio :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
form_for @user do |f|
== Examples
to convert these text/value. Based on collection_select.
text/value option in the collection, using value_method and text_method
helper will create a radio input associated with a label for each
Create a collection of radio inputs for the attribute. Basically this
def collection_radio(attribute, collection, value_method, text_method, options={}, html_options={}) collection.inject('') do |result, item| value = item.send value_method text = item.send text_method default_html_options = default_html_options_for_collection(item, value, options, html_options) radio = radio_button(attribute, value, default_html_options) result << label("#{attribute}_#{value}", radio << text.to_s, :class => "collection_radio") end end