check_box_tag not passing 0 when unchecked?

Taylor Strait wrote:

Code:
<%= check_box_tag("person[#{person.id}][is_approved]", 1, true) %>

Rendered output:
<input checked="checked" id="person[7][is_approved]"
name="person[7][is_approved]" value="1" type="checkbox">

Problem:
The value of "1" is always passed, even if the box is UNCHECKED.
Suggestions? Thanks!

http://www.ruby-forum.com/topic/60783

You’ll have to add your own hidden checkbox input then. There’s no other way around it really. Sometimes it helps to write your own helper for it though. One less thing to remember and it’s DRY.

RSL

:index fixed it? Care to explicate or should I just dig in the source? [Hint, hint.] :slight_smile:

RSL

Cool.

RSL

Very cool. I’ve needed something like that before. Wish I’d known that then!