From f991c8dd72c124632ac841cc06e04073929b6435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 27 Dec 2012 13:03:46 -0300 Subject: [PATCH] Fix SimpleForm bug when passing :name => nil as a options. Since https://github.com/rails/rails/commit/f0a5d325375d9f453d4cc6c6bf555561e52d4ea7 if you pass :name => nil to an input it will not generate the automatic name. This issue was hidden because country_select has reimplemented add_default_name_and_id on ActionView::Helpers::Tags::Base. --- lib/simple_form/inputs/boolean_input.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/simple_form/inputs/boolean_input.rb b/lib/simple_form/inputs/boolean_input.rb index 060ad8be..4fa854c9 100644 --- a/lib/simple_form/inputs/boolean_input.rb +++ b/lib/simple_form/inputs/boolean_input.rb @@ -49,9 +49,10 @@ module SimpleForm # we need the hidden field to be *outside* the label (otherwise it # generates invalid html - html5 only). def build_hidden_field_for_checkbox - @builder.hidden_field(attribute_name, :value => unchecked_value, :id => nil, - :disabled => input_html_options[:disabled], - :name => input_html_options[:name]) + options = { value: unchecked_value, id: nil, disabled: input_html_options[:disabled] } + options[:name] = input_html_options[:name] if input_html_options.has_key?(:name) + + @builder.hidden_field(attribute_name, options) end def inline_label