Merge pull request #482 from ehoch/master

Allow inline_label for booleans
This commit is contained in:
Carlos Antonio da Silva 2012-03-01 08:31:04 -08:00
commit 2830fd37ff
4 changed files with 14 additions and 2 deletions

View File

@ -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 File

@ -72,4 +72,4 @@ DEPENDENCIES
rake
rdoc
simple_form!
tzinfo
tzinfo

View File

@ -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

View File

@ -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