Skip to content

Commit 99cf4c8

Browse files
Improve the Model "optional" method functionality for empty values
1 parent faa6672 commit 99cf4c8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎application/core/EA_Model.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,12 @@ public function optional(array &$record, array $fields)
189189
{
190190
if (is_assoc($record)) {
191191
foreach ($fields as $field => $default) {
192-
$record[$field] = $record[$field] ?? $default;
192+
$record[$field] = $record[$field] ?? null ?: $default;
193193
}
194194
} else {
195195
foreach ($record as &$record_item) {
196196
foreach ($fields as $field => $default) {
197-
$record_item[$field] = $record_item[$field] ?? $default;
197+
$record_item[$field] = $record_item[$field] ?? null ?: $default;
198198
}
199199
}
200200
}

0 commit comments

Comments
 (0)