提交 8091ed54 编写于 作者: J Jeremy Kemper

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
上级 c8b6b482
*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]
......
......@@ -486,7 +486,7 @@ def to_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0")
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()
......
......@@ -172,6 +172,13 @@ def test_check_box_with_explicit_checked_and_unchecked_values
)
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")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册