aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb2
-rw-r--r--actionpack/test/template/form_helper_test.rb7
3 files changed, 10 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index cb88f5fa24..7adad721fc 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Disabled checkboxes don't submit a form value. #9301 [vladr, robinjfisher]
+
* Added tests for options to ActiveRecordHelper#form. Closes #7213 [richcollins, mikong, mislav]
* Changed before_filter halting to happen automatically on render or redirect but no longer on simply returning false [DHH]
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index f25f47af62..cc81bad2b4 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -486,7 +486,7 @@ module ActionView
end
options["checked"] = "checked" if checked
add_default_name_and_id(options)
- tag("input", options) << tag("input", "name" => options["name"], "type" => "hidden", "value" => unchecked_value)
+ tag("input", options) << tag("input", "name" => options["name"], "type" => "hidden", "value" => options['disabled'] && checked ? checked_value : unchecked_value)
end
def to_date_tag()
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 32529c66f7..d00bd16ad8 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -172,6 +172,13 @@ class FormHelperTest < Test::Unit::TestCase
)
end
+ def test_checkbox_disabled_still_submits_checked_value
+ assert_dom_equal(
+ '<input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="1" />',
+ check_box("post", "secret", { :disabled => :true })
+ )
+ end
+
def test_radio_button
assert_dom_equal('<input checked="checked" id="post_title_hello_world" name="post[title]" type="radio" value="Hello World" />',
radio_button("post", "title", "Hello World")