Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

check_box helper with :disabled => true generates disabled hidden field. fixes #1953 (master) #4337

Merged
merged 1 commit into from

2 participants

Tadas Tamošauskas José Valim
Tadas Tamošauskas

This is a rebased version of #3698, fixes #1953

José Valim josevalim merged commit 37b4ba2 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 5, 2012
  1. check_box helper with :disabled => true generates disabled hidden fie…

    Tadas Tamošauskas authored
    …ld. fixes #1953
This page is out of date. Refresh to see the latest.
4 actionpack/CHANGELOG.md
View
@@ -1,5 +1,9 @@
## Rails 3.2.0 (unreleased) ##
+* check_box helper with :disabled => true will generate a disabled hidden field to conform with the HTML convention where disabled fields are not submitted with the form.
+ This is a behavior change, previously the hidden tag had a value of the disabled checkbox.
+ *Tadas Tamosauskas*
+
* Add font_path helper method *Santiago Pastorino*
* Depends on rack ~> 1.4.0 *Santiago Pastorino*
2  actionpack/lib/action_view/helpers/form_helper.rb
View
@@ -1091,7 +1091,7 @@ def to_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0")
else
add_default_name_and_id(options)
end
- hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => options['disabled'] && checked ? checked_value : unchecked_value)
+ hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => unchecked_value, "disabled" => options["disabled"])
checkbox = tag("input", options)
hidden + checkbox
end
7 actionpack/test/template/form_helper_test.rb
View
@@ -386,11 +386,10 @@ def test_check_box_with_multiple_behavior
)
end
-
- def test_checkbox_disabled_still_submits_checked_value
+ def test_checkbox_disabled_disables_hidden_field
assert_dom_equal(
- '<input name="post[secret]" type="hidden" value="1" /><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
- check_box("post", "secret", { :disabled => :true })
+ '<input name="post[secret]" type="hidden" value="0" disabled="disabled"/><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
+ check_box("post", "secret", { :disabled => true })
)
end
Something went wrong with that request. Please try again.