diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-23 19:25:28 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-23 19:25:28 +0000 |
commit | 8091ed54205a20f3756be3af0d64f98d59276c1d (patch) | |
tree | aaa4c88d7b2f4af18eb1166b20b38eef67586734 /actionpack | |
parent | c8b6b4821ff3f8135a22728bdf989e585a38d343 (diff) | |
download | rails-8091ed54205a20f3756be3af0d64f98d59276c1d.tar.gz rails-8091ed54205a20f3756be3af0d64f98d59276c1d.tar.bz2 rails-8091ed54205a20f3756be3af0d64f98d59276c1d.zip |
Disabled checkboxes don't submit a form value. Closes #9301.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8007 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 7 |
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") |