1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

add include_hidden option to checkbox tag

This commit is contained in:
Sergey Nartimov 2012-03-13 23:17:49 +03:00
parent a85714a673
commit 9fbb1767b5
2 changed files with 13 additions and 2 deletions

View file

@ -25,9 +25,15 @@ module ActionView
add_default_name_and_id(options)
end
hidden = hidden_field_for_checkbox(options)
include_hidden = options.delete("include_hidden") { true }
checkbox = tag("input", options)
hidden + checkbox
if include_hidden
hidden = hidden_field_for_checkbox(options)
hidden + checkbox
else
checkbox
end
end
private

View file

@ -387,6 +387,11 @@ class FormHelperTest < ActionView::TestCase
)
end
def test_check_box_with_include_hidden_false
@post.secret = false
assert_dom_equal('<input id="post_secret" name="post[secret]" type="checkbox" value="1" />', check_box("post", "secret", :include_hidden => false))
end
def test_check_box_with_explicit_checked_and_unchecked_values
@post.secret = "on"
assert_dom_equal(