Permalink
Browse files

Merge pull request #482 from ehoch/master

Allow inline_label for booleans
  • Loading branch information...
2 parents dfa05ba + f8a159e commit 2830fd37ff9ff8b6bb2388d404704a88dfa9b8c2 @carlosantoniodasilva carlosantoniodasilva committed Mar 1, 2012
Showing with 14 additions and 2 deletions.
  1. +3 −0 CHANGELOG.md
  2. +1 −1 Gemfile.lock
  3. +1 −1 lib/simple_form/inputs/boolean_input.rb
  4. +9 −0 test/inputs/boolean_input_test.rb
View
3 CHANGELOG.md
@@ -6,6 +6,9 @@
## 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)
View
2 Gemfile.lock
@@ -72,4 +72,4 @@ DEPENDENCIES
rake
rdoc
simple_form!
- tzinfo
+ tzinfo
View
2 lib/simple_form/inputs/boolean_input.rb
@@ -5,7 +5,7 @@ def input
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
View
9 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

0 comments on commit 2830fd3

Please sign in to comment.