diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index f408c503906a612bfcb950954aaf0b2b76533acd..a5370afcf15a4a00802fe95869ea63fe22fa5bc9 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -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* diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 1e4bebeee7bcec0fc6a3b39b2d27e3405f81a13d..08c7fbc2812d80a3554767618b4b396b9c583dc4 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -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 diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 6fe4ce65cfa130d71b1922bbf5752b709ee4c8de..9a13d4e399750826d2dc5ef81740c722cc4d4c73 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -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( - '', - check_box("post", "secret", { :disabled => :true }) + '', + check_box("post", "secret", { :disabled => true }) ) end