checkboxes not working correctly?

OK so I have a form that has a checkbox:

$death=new Check('death');

When the page renders the form handle looks like this:

<input type="checkbox" id="death" name="death" placeholder="Death" />

when the form is submitted, in the controller if the checkbox is not checked the variable is not passed in $_POST which is as expected and standard HTML behavior. But when the checkbox is checked it is passing back the number 0 instead of "on" or the number 1. Is this a bug?


$death->setAttribute('value', 1); ?

edited Feb '15

yup that worked. But shouldn't that be implicit?


No, that isn't implicit, because the checkbox will have a null default value (but the fact is that you getted a 0 instead of "", intval(..) maybe?)


null = 0, and value unset = null when checked. so when u do a vardump it will give u a 0, however if u do a if $value === null it will pass but $value === 0 will fail i believe =d