Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
how best to typecast bool before database entry using fieldsets
  • When a boolean/checkbox form field is not checked, I get a database constraint error on save:
    Integrity constraint violation: 1048 Column 'is_a_business' cannot be null

    When I enable the typecasting observer and configure the column's $_properties to have 'data_type'=>'bool' and 'null'=>false, I get this error:
    Orm\InvalidContentType [ Error ]: The property "is_a_business" cannot be NULL.

    I don't want to put in custom code for every single boolean/checkbox field in my app.  What's a good way to solve this problem? I can just allow null in the database, but in my understanding that's less efficient?  Maybe I'm over-optimizing again, though.
  • HarroHarro
    Accepted Answer
    if it's not allowed to be null, you also have to define a 'default' value for the property, which the typing observer will assign if the value is null.
  • Cool, thank you.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion