Skip to content

Commit

Permalink
Honor include_hidden on inline boolean inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
yboulkaid committed May 10, 2022
1 parent 2320520 commit 27e5102
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/simple_form/inputs/boolean_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ def input(wrapper_options = nil)
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

Expand Down
5 changes: 5 additions & 0 deletions test/inputs/boolean_input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 27e5102

Please sign in to comment.