Skip to main content
Topic: Error 500 with checkbox and SingleSwitch using 0 and 1 values (Read 1692 times) previous topic - next topic

Error 500 with checkbox and SingleSwitch using 0 and 1 values

Hello all,
I can't make it work using a Checkbox and SingleSwitch option using values different than 'true' and 'false'.
I have a field that should be 0 or 1.
If I set the field as Checkbox and set is as SingleSwitch, setting CheckValue to 1 and UnCheckValue to 0 I get error 500:
SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'false' for column `my_db`.`stores`.`approved` at row 1

Please note the 'false' value in the error. Where it is coming from?

Is this a bug?

As a workaround I've set this field as SELECT.

TIA
tony

Re: Error 500 with checkbox and SingleSwitch using 0 and 1 values

Reply #1
@sweetman‍ The best solution to avoid any error is to set the database column to varchar. but from the SQL error you posted, it seems the database field is set to DateTime.

[SOLVED] Re: Error 500 with checkbox and SingleSwitch using 0 and 1 values

Reply #2
@sweetman‍ The best solution to avoid any error is to set the database column to varchar. but from the SQL error you posted, it seems the database field is set to DateTime.
Hello Willvin,
in the db the field is set to INT, actually.
Changing the fieldtype to varchar seems to solve the problem.
Thanks for your help.
Tony