Add extra "checkbox" class to label with nested style enabled using :label_input in wrapper config

This commit is contained in:
Timur Vafin 2012-02-04 01:58:06 +04:00
parent b36a9d2c53
commit 8f800a72d0
2 changed files with 14 additions and 1 deletions

View File

@ -16,8 +16,11 @@ module SimpleForm
if options[:label] == false
input
elsif nested_boolean_style?
html_options = label_html_options.dup
html_options[:class].push(:checkbox)
build_hidden_field_for_checkbox +
@builder.label(label_target, label_html_options) {
@builder.label(label_target, html_options) {
build_check_box_without_hidden_field + label_text
}
else

View File

@ -88,4 +88,14 @@ class BooleanInputTest < ActionView::TestCase
end
end
end
test 'input boolean with nested style works using :label_input in wrapper config, adding "checkbox" class to label' do
swap_wrapper :default, self.custom_wrapper_without_top_level do
swap SimpleForm, :boolean_style => :nested do
with_input_for @user, :active, :boolean
assert_select 'input[type=hidden] + label.boolean.checkbox > input.boolean'
end
end
end
end