Merge pull request #482 from ehoch/master
Allow inline_label for booleans
This commit is contained in:
commit
2830fd37ff
|
@ -6,6 +6,9 @@
|
||||||
|
|
||||||
## 2.0.1
|
## 2.0.1
|
||||||
|
|
||||||
|
### enhancements
|
||||||
|
* Add `:inline_label` configuration to nested booleans to display text inline with checkbox. ([@ehoch](https://github.com/ehoch))
|
||||||
|
|
||||||
### bug fix
|
### bug fix
|
||||||
* Sanitaze html attributes to `label` method. ([@nashby](https://github.com/nashby)).
|
* Sanitaze html attributes to `label` method. ([@nashby](https://github.com/nashby)).
|
||||||
Closes [#472](https://github.com/plataformatec/simple_form/issues/472)
|
Closes [#472](https://github.com/plataformatec/simple_form/issues/472)
|
||||||
|
|
|
@ -5,7 +5,7 @@ module SimpleForm
|
||||||
if nested_boolean_style?
|
if nested_boolean_style?
|
||||||
build_hidden_field_for_checkbox +
|
build_hidden_field_for_checkbox +
|
||||||
template.label_tag(nil, :class => "checkbox") {
|
template.label_tag(nil, :class => "checkbox") {
|
||||||
build_check_box_without_hidden_field
|
build_check_box_without_hidden_field + options[:inline_label]
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
build_check_box
|
build_check_box
|
||||||
|
|
|
@ -29,6 +29,13 @@ class BooleanInputTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
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
|
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
|
swap SimpleForm, :boolean_style => :nested do
|
||||||
with_input_for @user, :active, :boolean
|
with_input_for @user, :active, :boolean
|
||||||
|
@ -98,4 +105,6 @@ class BooleanInputTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue