GC 3.0.4: callbackReadField not functional if DB field is null?


I try to use callbackReadField for view form, but
if underlying DB-field (“data”) is null
nothing happens: it is no data in “data”-field displayed and it’s no log-entry for it too:

$crud->callbackReadField('data', function ($value, $row) {
            log_message('debug', 'callback read');
            return 'XXXXXXXXXXXX';

The “callbackColumn”-method works as expected in lists independent of DB value.

How to fix it?
(GC 3.0.4 with Codeigniter 4.3.4)


The problem you’re facing might be due to the way the callbackReadField function is set up to handle NULL values. When the database field “data” is NULL, the callback function may not be executing as expected.

A possible solution is to modify your callback function to specifically handle NULL values. For example:
$crud->callbackReadField(‘data’, function ($value, $row) {
log_message(‘debug’, ‘callback read’);
if ($value === null) {
// Handle null value
return ‘No data available’; // Or whatever you want to display for null values
return $value;
This will make sure that a value is returned even if the database field is NULL. The function now checks if the $value is null, and if it is, it returns a specific string (‘No data available’ in this example).

Please try this and let me know if it solves your problem. If it doesn’t, there may be other factors at play that we need to look into. Remember to check any error logs or debug information that could help identify the issue.


I’ve been working on implementing the callbackReadField for a view form, but I’ve encountered an issue. When the underlying database field (“data”) is null, nothing seems to happen. There’s no data displayed in the “data” field, and no log entry is generated either. Here’s the code snippet I’ve been using:

phpCopy code

$crud->setRead(); $crud->callbackReadField(‘data’, function ($value, $row) { log_message(‘debug’, ‘callback read’); return ‘XXXXXXXXXXXX’; });

Interestingly, the callbackColumn method works as expected in lists, regardless of the database value.

I’m wondering how I can resolve this issue. I’m using GC 3.0.4 with Codeigniter 4.3.4.

Thank you for your assistance.