Permalink
Browse files

Merge pull request #620 from carnesmedia/boolean_field_ignores_input_…

…html

Boolean hidden field uses name when :nested
  • Loading branch information...
rafaelfranca committed Jul 13, 2012
2 parents ddf2168 + a094034 commit 5548b2cb281bcf52ece2624535d861184649cf4f
Showing with 9 additions and 1 deletion.
  1. +2 −1 lib/simple_form/inputs/boolean_input.rb
  2. +7 −0 test/inputs/boolean_input_test.rb
@@ -50,7 +50,8 @@ def build_check_box_without_hidden_field
# generates invalid html - html5 only).
def build_hidden_field_for_checkbox
@builder.hidden_field(attribute_name, :value => '0', :id => nil,
- :disabled => input_html_options[:disabled])
+ :disabled => input_html_options[:disabled],
+ :name => input_html_options[:name])
end
def inline_label
@@ -84,6 +84,13 @@ class BooleanInputTest < ActionView::TestCase
end
end
+ test 'input with nested style allows customizing input_html' do
+ swap SimpleForm, :boolean_style => :nested do
+ with_input_for @user, :active, :boolean, :input_html => { :name => 'active_user' }
+ assert_select "input[type=hidden][name=active_user] + label.boolean > input.boolean[name=active_user]"
+ end
+ end
+
test 'input boolean works using :input only in wrapper config (no label_input)' do
swap_wrapper do
with_input_for @user, :active, :boolean

0 comments on commit 5548b2c

Please sign in to comment.