Skip to content

Commit

Permalink
Use form attribute in the boolean nested hidden field
Browse files Browse the repository at this point in the history
Fixes #1545
  • Loading branch information
feliperenan committed Oct 6, 2018
1 parent 67d8df4 commit 87ad6f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
## Unreleased

### Enhancements
* Guess input type more carefully. [sringling](https://github.com/sringling)
* Allow custom error on forms without model. [victorperez](https://github.com/victorperez)
* Guess input type more carefully. [@sringling](https://github.com/sringling)
* Allow custom error on forms without model. [@victorperez](https://github.com/victorperez)

### Bug fix
* Improve disabled option to input_field. [betelgeuse](https://github.com/betelgeuse)
* Improve disabled option to input_field. [@betelgeuse](https://github.com/betelgeuse)
* Memoize `input_html_classes` in `SimpleForm::Inputs::Base`. [@RigoTheDev](https://github.com/RigoTheDev)
* Fix column type citext HTML5 input type bug. [@brucew](https://github.com/brucew)
* Use form attribute in the nested boolean hidden field when it is given. [@feliperenan](https://github.com/feliperenan)

## 4.0.1

Expand Down
1 change: 1 addition & 0 deletions lib/simple_form/inputs/boolean_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def build_hidden_field_for_checkbox
return "" if !include_hidden? || !unchecked_value
options = { value: unchecked_value, id: nil, disabled: input_html_options[:disabled] }
options[:name] = input_html_options[:name] if input_html_options.key?(:name)
options[:form] = input_html_options[:form] if input_html_options.key?(:form)

@builder.hidden_field(attribute_name, options)
end
Expand Down
8 changes: 8 additions & 0 deletions test/inputs/boolean_input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ class BooleanInputTest < ActionView::TestCase
end
end

test 'input boolean with nested generates a disabled hidden field with the form attribute when it is given' do
swap SimpleForm, boolean_style: :nested do
with_input_for @user, :active, :boolean, input_html: { form: 'form_id' }

assert_select "input[type=hidden][form=form_id]+ label.boolean > input.boolean"
end
end

test 'input accepts changing boolean style to nested through given options' do
with_input_for @user, :active, :boolean, boolean_style: :nested
assert_select 'label[for=user_active]', 'Active'
Expand Down

0 comments on commit 87ad6f7

Please sign in to comment.