Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix collection_radio_buttons with the option `:checked` with value of

`false`
  • Loading branch information...
commit ceedec7edcadbad824f58e84bc2c1eddbe8539ce 1 parent b05819f
@rafaelfranca rafaelfranca authored
View
3  actionpack/lib/action_view/helpers/tags/collection_helpers.rb
@@ -44,7 +44,8 @@ def default_html_options_for_collection(item, value) #:nodoc:
html_options = @html_options.dup
[:checked, :selected, :disabled].each do |option|
- next unless current_value = @options[option]
+ current_value = @options[option]
+ next if current_value.nil?
accept = if current_value.respond_to?(:call)
current_value.call(item)
View
6 actionpack/test/template/form_collections_helper_test.rb
@@ -149,6 +149,12 @@ def with_collection_check_boxes(*args, &block)
assert_select 'label[for=post_category_id_2]', 'Category 2'
end
+ test 'collection radio accepts checked item which has a value of false' do
+ with_collection_radio_buttons :user, :active, [[1, true], [0, false]], :last, :first, :checked => false
+ assert_no_select 'input[type=radio][value=true][checked=checked]'
+ assert_select 'input[type=radio][value=false][checked=checked]'
+ end
+
# COLLECTION CHECK BOXES
test 'collection check boxes accepts a collection and generate a serie of checkboxes for value method' do
collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')]

1 comment on commit ceedec7

Please sign in to comment.
Something went wrong with that request. Please try again.