module SimpleForm::ActionViewExtensions::Builder
def collection_radio_buttons(attribute, collection, value_method, text_method, options={}, html_options={})
* a block => to generate the label + radio or any other component.
* item_wrapper_class => the CSS class to use for item_wrapper_tag
* item_wrapper_tag => the tag to wrap each item in the collection.
* collection_wrapper_class => the CSS class to use for collection_wrapper_tag
* collection_wrapper_tag => the tag to wrap the entire collection.
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
end
b.label { b.radio_button + b.text }
) do |b|
:options, [[true, 'Yes'] ,[false, 'No']], :first, :last
f.collection_radio_buttons(
form_for @user do |f|
label. To wrap the radio with the label, for instance:
It is also possible to give a block that should generate the radio +
end
f.collection_radio_buttons :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
form_for @user do |f|
== Examples
the collection.
value_method and text_method, that will be evaluated for each item in
to convert these text/value. You can give a symbol or a proc to both
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_buttons(attribute, collection, value_method, text_method, options={}, html_options={}) rendered_collection = render_collection( collection, value_method, text_method, options, html_options ) do |item, value, text, default_html_options| builder = instantiate_builder(RadioButtonBuilder, attribute, item, value, text, default_html_options) if block_given? yield builder else builder.radio_button + builder.label(:class => "collection_radio_buttons") end end wrap_rendered_collection(rendered_collection, options) end