In my database I have a required tinyint field that stores a 0 for false or a 1 for true. On my edit form I use a Form->checkbox(‘deleted’). There is an automatic hiddenField with a default value of zero. Therefore, if I check the box I get a 1 and if I un-check the box I should get a 0 but instead I get a message when I submit the form that says “Please check this box if you want to proceed.”
The HTML output is adding a required tag parameter which I believe is causing the issue.
How can I get the form to accept an un-checked checkbox with a value of 0
The database already has the default = 0 for the column. Adding a new record is not an issue. But if I edit a record, check the box, submit the form, the database field is set to 1. Good so far. Now if I go back in to edit and try to un-check the field, I get the message “Please check this box if you want to proceed.” The form does not submit. I can only check the field and submit the form.
So, you have a box that says you have to check it in order to proceed, and you’re complaining that if you don’t check it, it won’t let you proceed? This seems like it’s behaving as designed?
If you really need it to accept a “must be checked to proceed” box without it being checked, it seems like the place this is most likely coming from is your validation, which isn’t shown here.
Ah, this is one of those built-in browser things that completely prevent the form from submitting, not an error message that appears when the page is refreshed after submitting? Can’t remember off the top of my head how to get rid of the “required” attribute that Cake puts on things, that’s presumably what’s causing this. Alternately, look up the “novalidate” option in HTML.