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
上级 e5b3d08a
*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]
......
......@@ -199,7 +199,7 @@ def to_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0")
else
value.to_i != 0
end
if checked
if checked || options["checked"] == "checked"
options["checked"] = "checked"
else
options.delete("checked")
......
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 @@ def test_check_box
'<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" />',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册