Default Value for checkbox_boolean

Hi, I have a field which is of type checkbox_boolean. I’m trying to have it selected by default.

using callbackAddForm i’m not sure what is the value it should have.

I tried values: true, “true”, “t”, 1, “1”

None of which worked.

Is it even possible?
Thanks.

Hello @DavidBinaud ,

It seems like there is a bug on Grocery CRUD Enterprise for the default value for checkbox_boolean. No matter the value that you add on callbackAddForm the default database value always win. As a work-around (if you can of course) change the default value of the database to be “1” (also see screenshot from phpmyadmin)

If you can’t do that for now as a workaround use the field type ‘dropdown’ like this:

$crud->fieldType('enabled', 'dropdown', [
    '0' => 'no',
    '1' => 'yes',
]);

Of course, I am keeping it a not in order to fix that for the next version.

Regards
Johnny