From eae5fb7e9a2ebfedcd938ed48ca87103cb4772e1 Mon Sep 17 00:00:00 2001 From: Jacek Tomaszewski Date: Sun, 2 Feb 2014 21:03:17 +0100 Subject: [PATCH] Add :inline option to Radio and CheckBoxesInput. After passing `inline: true` option to `:radio` or `:check_boxes` input, input container will be rendered with `.radio-inline` or `.checkbox-inline` class. --- lib/formtastic-bootstrap/inputs/check_boxes_input.rb | 5 +++-- lib/formtastic-bootstrap/inputs/radio_input.rb | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/formtastic-bootstrap/inputs/check_boxes_input.rb b/lib/formtastic-bootstrap/inputs/check_boxes_input.rb index bc9b8d1e..05c55eb9 100644 --- a/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +++ b/lib/formtastic-bootstrap/inputs/check_boxes_input.rb @@ -5,7 +5,6 @@ class CheckBoxesInput < Formtastic::Inputs::CheckBoxesInput include Base::Choices # TODO Make sure help blocks work correctly. - # TODO Support .inline def to_html form_group_wrapping do @@ -30,9 +29,11 @@ def choice_html(choice) end def checkbox_wrapping(&block) + class_name = "checkbox" + class_name += " checkbox-inline" if options[:inline] template.content_tag(:div, template.capture(&block).html_safe, - :class => "checkbox" + :class => class_name ) end diff --git a/lib/formtastic-bootstrap/inputs/radio_input.rb b/lib/formtastic-bootstrap/inputs/radio_input.rb index f68502d8..80edccce 100644 --- a/lib/formtastic-bootstrap/inputs/radio_input.rb +++ b/lib/formtastic-bootstrap/inputs/radio_input.rb @@ -5,7 +5,6 @@ class RadioInput < Formtastic::Inputs::RadioInput include Base::Choices # TODO Make sure help blocks work correctly. - # TODO Support .inline def to_html form_group_wrapping do @@ -35,9 +34,11 @@ def choice_html(choice) end def radio_wrapping(&block) + class_name = "radio" + class_name += " radio-inline" if options[:inline] template.content_tag(:div, template.capture(&block).html_safe, - :class => "radio" + :class => class_name ) end