From 528b6f35ca663acd5aeaf665f1001206cbef2e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franc=CC=A7ois=20Beausoleil?= Date: Mon, 1 Apr 2013 21:26:38 -0400 Subject: [PATCH 1/2] Support #select's html_options argument By calling the helper with an `:html` key, we can style the underlying select with a class: <%= f.select :language, nil, html: { class: "span1" } %> --- lib/twitter_bootstrap_form_for/form_builder.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/twitter_bootstrap_form_for/form_builder.rb b/lib/twitter_bootstrap_form_for/form_builder.rb index 1b54fbe..e9e9645 100644 --- a/lib/twitter_bootstrap_form_for/form_builder.rb +++ b/lib/twitter_bootstrap_form_for/form_builder.rb @@ -87,6 +87,7 @@ def inline(label = nil, &block) INPUTS.each do |input| define_method input do |attribute, *args, &block| options = args.extract_options! + html_options = options.delete(:html) label = args.first.nil? ? '' : args.shift classes = [ 'controls', 'input' ] classes << ('input-' + options.delete(:add_on).to_s) if options[:add_on] @@ -95,7 +96,9 @@ def inline(label = nil, &block) template.concat self.label(attribute, label) if label template.concat template.content_tag(:div, :class => classes.join(' ')) { block.call if block.present? and classes.include?('input-prepend') - template.concat super(attribute, *(args << options)) + final_args = args << options + final_args << html_options if html_options + template.concat super(attribute, *final_args) template.concat error_span(attribute) block.call if block.present? and classes.include?('input-append') } From d857d3ea2a48c92ffbd6a53a8bba9b13381f7814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franc=CC=A7ois=20Beausoleil?= Date: Tue, 7 May 2013 09:38:56 -0400 Subject: [PATCH 2/2] Fixed labels on radio/checkbox didn't have appropriate class per-Bootstrap's --- lib/twitter_bootstrap_form_for/form_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/twitter_bootstrap_form_for/form_builder.rb b/lib/twitter_bootstrap_form_for/form_builder.rb index e9e9645..a4adc18 100644 --- a/lib/twitter_bootstrap_form_for/form_builder.rb +++ b/lib/twitter_bootstrap_form_for/form_builder.rb @@ -110,7 +110,7 @@ def inline(label = nil, &block) define_method toggle do |attribute, *args, &block| label = args.first.nil? ? '' : args.shift target = self.object_name.to_s + '_' + attribute.to_s - label_attrs = toggle == :check_box ? { :for => target } : {} + label_attrs = toggle == :check_box ? { :for => target, :class => "checkbox" } : { :class => "radio" } template.content_tag(:li) do template.concat template.content_tag(:label, label_attrs) {