From a0ea7e4e0cd1e20cd4cae2991ce4f03c7746ec14 Mon Sep 17 00:00:00 2001 From: Eric Hochberger Date: Wed, 29 Feb 2012 16:36:25 -0500 Subject: [PATCH 1/3] Allow inline_label for booleans --- lib/simple_form/inputs/boolean_input.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/simple_form/inputs/boolean_input.rb b/lib/simple_form/inputs/boolean_input.rb index 7ada93f1..62a7839f 100644 --- a/lib/simple_form/inputs/boolean_input.rb +++ b/lib/simple_form/inputs/boolean_input.rb @@ -5,7 +5,7 @@ module SimpleForm if nested_boolean_style? build_hidden_field_for_checkbox + template.label_tag(nil, :class => "checkbox") { - build_check_box_without_hidden_field + build_check_box_without_hidden_field + options[:inline_label] } else build_check_box From a1d8a727120e37a901e297ab9ae697bdca4c48ff Mon Sep 17 00:00:00 2001 From: Eric Hochberger Date: Thu, 1 Mar 2012 10:35:36 -0500 Subject: [PATCH 2/3] changelog and test --- CHANGELOG.md | 3 +++ Gemfile.lock | 6 +++--- test/inputs/boolean_input_test.rb | 9 +++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index deb389a2..3a153d09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## 2.0.1 +### enhancements + * Add `:inline_label` configuration to nested booleans to display text inline with checkbox. ([@ehoch](https://github.com/ehoch)) + ### bug fix * Sanitaze html attributes to `label` method. ([@nashby](https://github.com/nashby)). Closes [#472](https://github.com/plataformatec/simple_form/issues/472) diff --git a/Gemfile.lock b/Gemfile.lock index d4c1823e..541d594b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,12 +29,12 @@ GEM erubis (2.7.0) hike (1.2.1) i18n (0.6.0) - journey (1.0.1) + journey (1.0.3) json (1.6.5) metaclass (0.0.1) - mocha (0.10.3) + mocha (0.10.5) metaclass (~> 0.0.1) - multi_json (1.0.4) + multi_json (1.1.0) rack (1.4.1) rack-cache (1.1) rack (>= 0.4) diff --git a/test/inputs/boolean_input_test.rb b/test/inputs/boolean_input_test.rb index 4f6c4601..56085261 100644 --- a/test/inputs/boolean_input_test.rb +++ b/test/inputs/boolean_input_test.rb @@ -29,6 +29,13 @@ class BooleanInputTest < ActionView::TestCase end end + test 'input boolean with nested allows :inline_label' do + swap SimpleForm, :boolean_style => :nested do + with_input_for @user, :active, :boolean, :label => false, :inline_label => 'I am so inline.' + assert_select 'label.checkbox', :text => 'I am so inline.' + end + end + test 'input boolean with nested generates a manual hidden field for checkbox outside the label, to recreate Rails functionality with valid html5' do swap SimpleForm, :boolean_style => :nested do with_input_for @user, :active, :boolean @@ -98,4 +105,6 @@ class BooleanInputTest < ActionView::TestCase end end end + + end From f8a159eb1476e188b0d04078ec3a8c683d61115c Mon Sep 17 00:00:00 2001 From: Eric Hochberger Date: Thu, 1 Mar 2012 11:19:53 -0500 Subject: [PATCH 3/3] remove gemfile update --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 541d594b..547495b5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,12 +29,12 @@ GEM erubis (2.7.0) hike (1.2.1) i18n (0.6.0) - journey (1.0.3) + journey (1.0.1) json (1.6.5) metaclass (0.0.1) - mocha (0.10.5) + mocha (0.10.3) metaclass (~> 0.0.1) - multi_json (1.1.0) + multi_json (1.0.4) rack (1.4.1) rack-cache (1.1) rack (>= 0.4) @@ -72,4 +72,4 @@ DEPENDENCIES rake rdoc simple_form! - tzinfo + tzinfo \ No newline at end of file