Improve the Model "optional" method functionality for empty values

This commit is contained in:
Alex Tselegidis 2024-08-13 13:23:51 +02:00
parent faa66723f9
commit 99cf4c8da2

View file

@ -189,12 +189,12 @@ class EA_Model extends CI_Model
{
if (is_assoc($record)) {
foreach ($fields as $field => $default) {
$record[$field] = $record[$field] ?? $default;
$record[$field] = $record[$field] ?? null ?: $default;
}
} else {
foreach ($record as &$record_item) {
foreach ($fields as $field => $default) {
$record_item[$field] = $record_item[$field] ?? $default;
$record_item[$field] = $record_item[$field] ?? null ?: $default;
}
}
}