Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

extract checked_value and unchecked_value before passing options to t…

…he check_box helper so as not to make them attributes of the resulting input HTML element
  • Loading branch information...
commit 281ea9890aaa0900a6fb18d209fb278b5e58a66b 1 parent 19257b2
Moritz Heidkamp authored committed
Showing with 4 additions and 2 deletions.
  1. +3 −1 lib/formtastic.rb
  2. +1 −1  spec/inputs/boolean_input_spec.rb
View
4 lib/formtastic.rb
@@ -1205,9 +1205,11 @@ def boolean_input(method, options)
html_options = options.delete(:input_html) || {}
checked = options.key?(:checked) ? options[:checked] : options[:selected]
html_options[:checked] = checked == true if [:selected, :checked].any? { |k| options.key?(k) }
+ checked_value = options.delete(:checked_value) || '1'
+ unchecked_value = options.delete(:unchecked_value) || '0'
input = self.check_box(method, strip_formtastic_options(options).merge(html_options),
- options.delete(:checked_value) || '1', options.delete(:unchecked_value) || '0')
+ checked_value, unchecked_value)
options = options_for_label(options)
# the label() method will insert this nested input into the label at the last minute
View
2  spec/inputs/boolean_input_spec.rb
@@ -38,7 +38,7 @@
concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'checked', :unchecked_value => 'unchecked'))
end
- output_buffer.should have_tag('form li label input[@type="checkbox"][@value="checked"]')
+ output_buffer.should have_tag('form li label input[@type="checkbox"][@value="checked"]:not([@unchecked_value][@checked_value])')
output_buffer.should have_tag('form li label input[@type="hidden"][@value="unchecked"]')
end
Please sign in to comment.
Something went wrong with that request. Please try again.