Skip to content
Browse files

Merge pull request #5420 from lest/patch-2

add include_hidden option to checkbox tag
  • Loading branch information...
2 parents 919db1b + 9fbb176 commit 663b66fd538fc2f637f09bb27aad65449585f226 @drogus drogus committed Mar 13, 2012
View
10 actionpack/lib/action_view/helpers/tags/check_box.rb
@@ -25,9 +25,15 @@ def render
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
5 actionpack/test/template/form_helper_test.rb
@@ -387,6 +387,11 @@ def test_check_box
)
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(

0 comments on commit 663b66f

Please sign in to comment.
Something went wrong with that request. Please try again.