Class: FormtasticBootstrap::Inputs::RadioInput
- Inherits:
-
Formtastic::Inputs::RadioInput
- Object
- Formtastic::Inputs::RadioInput
- FormtasticBootstrap::Inputs::RadioInput
- Includes:
- Base, Base::Choices
- Defined in:
- lib/formtastic-bootstrap/inputs/radio_input.rb
Instance Method Summary collapse
- #choice_html(choice) ⇒ Object
- #radio_wrapping(&block) ⇒ Object
-
#to_html ⇒ Object
TODO Make sure help blocks work correctly.
- #wrapper_html_options ⇒ Object
Methods included from Base::Choices
#choice_label_html_options, #choice_wrapping_html_options
Methods included from Base::Wrapping
#add_on_content, #add_on_wrapper_classes, #bootstrap_wrapping, #form_group_wrapping, #input_content, #prepended_or_appended?
Methods included from Base::Labelling
#label_html, #label_html_options
Methods included from Base::Hints
Methods included from Base::Errors
#error_first_html, #error_html, #error_list_html, #error_none_html, #error_sentence_html
Methods included from Base::Html
#form_control_input_html_options, #input_html_options
Instance Method Details
#choice_html(choice) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/formtastic-bootstrap/inputs/radio_input.rb', line 25 def choice_html(choice) radio_wrapping do template.content_tag(:label, builder.(input_name, choice_value(choice), .merge((choice)).merge(:required => false)) << choice_label(choice), .merge((choice)) ) end end |
#radio_wrapping(&block) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/formtastic-bootstrap/inputs/radio_input.rb', line 35 def radio_wrapping(&block) class_name = "radio" class_name += " radio-inline" if [:inline] template.content_tag(:div, template.capture(&block).html_safe, :class => class_name ) end |
#to_html ⇒ Object
TODO Make sure help blocks work correctly.
9 10 11 12 13 14 15 |
# File 'lib/formtastic-bootstrap/inputs/radio_input.rb', line 9 def to_html bootstrap_wrapping do collection.map { |choice| choice_html(choice) }.join("\n").html_safe end end |
#wrapper_html_options ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/formtastic-bootstrap/inputs/radio_input.rb', line 17 def # Formtastic marks these as 'radio' but Bootstrap does something # with that, so change it to 'radio_buttons'. super.tap do || [:class] = [:class].gsub("radio", "radio_buttons") end end |