mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
don't set the hidden checkbox value if it's nil
This commit is contained in:
committed by
Carlos Antonio da Silva
parent
19be5ea877
commit
defb751681
@@ -1092,7 +1092,7 @@ module ActionView
|
||||
else
|
||||
add_default_name_and_id(options)
|
||||
end
|
||||
hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => unchecked_value, "disabled" => options["disabled"])
|
||||
hidden = unchecked_value ? tag("input", "name" => options["name"], "type" => "hidden", "value" => unchecked_value, "disabled" => options["disabled"]) : ""
|
||||
checkbox = tag("input", options)
|
||||
(hidden + checkbox).html_safe
|
||||
end
|
||||
|
||||
@@ -373,6 +373,14 @@ class FormHelperTest < ActionView::TestCase
|
||||
)
|
||||
end
|
||||
|
||||
def test_check_box_with_nil_unchecked_value
|
||||
@post.secret = "on"
|
||||
assert_dom_equal(
|
||||
'<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" />',
|
||||
check_box("post", "secret", {}, "on", nil)
|
||||
)
|
||||
end
|
||||
|
||||
def test_check_box_with_multiple_behavior
|
||||
@post.comment_ids = [2,3]
|
||||
assert_dom_equal(
|
||||
|
||||
Reference in New Issue
Block a user