On form submit it works as expect when you check and uncheck the checkbox it stores the correct 0 and 1 in the boolean in the database.
But, I have tried setting the static value to 0 to uncheck the checkbox by default and it no longer adds the correct value to the database when you check it.
What am I doing wrong??
The outcome I want is on form load the checkbox is unchecked, but still add the correct boolean value into the database when you check it is 1 and unchecked is 0.
Just a bit of error in how checkboxes work — the value has nothing to do with the box being check or not; that is handled by the CHECKED attribute. The value is simply what is sent IF the box is checked. If the box is not checked then nothing is sent at all. That is where using a default value on the server side comes in. You set a value if nothing is sent.