Development

Rendering null boolean values with Grid4PHP

I’m a big fan of Grid4PHP for adding a quick CRUD user interface to a MySQL database.

I have a lot of boolean columns, like “is_telehealth” that need to start as NULL until we make a determination about the field’s value. Grid4PHP renders null booleans as “0” in the table/edit form. This is misleading, given it’s not actually a 0 value. If you add the ‘isnull’ attribute to the column it lets you save the null value, but it still renders as a “0”.

Using a custom formatter I was able to render an empty string (nothing) instead of “0” for these null booleans:

Leave a Reply

Your email address will not be published.