aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-17 09:39:01 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-17 09:39:01 +0000
commitba96827b3d05396b11491e36590c52a407ddb8a2 (patch)
tree0cbb0da56782cf3d8e35cab31b94a8bc922d9ba5
parente5b3d08a0a10169cc7d482d13d5b5429162206c4 (diff)
downloadrails-ba96827b3d05396b11491e36590c52a407ddb8a2.tar.gz
rails-ba96827b3d05396b11491e36590c52a407ddb8a2.tar.bz2
rails-ba96827b3d05396b11491e36590c52a407ddb8a2.zip
Fixed FormTagHelper#check_box to respect checked #1049 [DelynnB]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1183 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-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, 8 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index ec67d80fb2..464790dcf1 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed FormTagHelper#check_box to respect checked #1049 [DelynnB]
+
* Added that render_partial called from a controller will use the action name as default #828 [Dan Peterson]
* Added Element.toggle, Element.show, and Element.hide to the prototype javascript library. Toggle.display has been deprecated, but will still work #992 [Lucas Carlson]
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 007437b7ad..4e25eee071 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -199,7 +199,7 @@ module ActionView
else
value.to_i != 0
end
- if checked
+ if checked || options["checked"] == "checked"
options["checked"] = "checked"
else
options.delete("checked")
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 3f8033af1d..28e8865f38 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -1,6 +1,7 @@
require 'test/unit'
require 'erb'
require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_helper'
+require File.dirname(__FILE__) + '/../../../activesupport/lib/active_support/core_ext/hash' #for stringify keys
class FormHelperTest < Test::Unit::TestCase
include ActionView::Helpers::FormHelper
@@ -64,13 +65,15 @@ class FormHelperTest < Test::Unit::TestCase
'<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
check_box("post", "secret")
)
-
@post.secret = 0
assert_equal(
'<input id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
check_box("post", "secret")
)
-
+ assert_equal(
+ '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
+ check_box("post", "secret" ,{"checked"=>"checked"})
+ )
@post.secret = true
assert_equal(
'<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',