Merge pull request #1772 from yboulkaid/main

Honor `include_hidden` on inline boolean inputs
This commit is contained in:
Vasiliy Ermolovich 2022-07-13 19:33:29 +02:00 committed by GitHub
commit 486ff139b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -12,7 +12,11 @@ module SimpleForm
inline_label
}
else
build_check_box(unchecked_value, merged_input_options)
if include_hidden?
build_check_box(unchecked_value, merged_input_options)
else
build_check_box_without_hidden_field(merged_input_options)
end
end
end

View File

@ -33,6 +33,11 @@ class BooleanInputTest < ActionView::TestCase
assert_select 'input[type=hidden][value=off]'
end
test 'input allows skipping hidden input when setting :include_hidden to false' do
with_input_for @user, :active, :boolean, include_hidden: false
assert_no_select "input[type=hidden][name='user[active]']"
end
test 'input uses inline boolean style by default' do
with_input_for @user, :active, :boolean
assert_select 'input.boolean + label.boolean.optional'