Skip to content

Commit 61d289c

Browse files
swhite2fichtner
authored andcommitted
mvc: backwards compatibility for virtual field types in UIModelGrid
(cherry picked from commit 410f255) (cherry picked from commit 8ad24e8)
1 parent 7fb1520 commit 61d289c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/opnsense/mvc/app/library/OPNsense/Base/UIModelGrid.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ public function fetch(
132132
$searchFound = false;
133133
foreach ($fields as $fieldname) {
134134
$item = $row['%' . $fieldname] ?? $row[$fieldname] ?? ''; /* prefer search by description */
135+
if (!array_key_exists($fieldname, $row) && $record->$fieldname != null) {
136+
/**
137+
* Fallback, item is most likely virtual. Since the model has no knowledge
138+
* of these types, but the controller explicitly asked for it, include it in the result.
139+
* XXX this item should be a volatile field in the model.
140+
*/
141+
$item = $record->$fieldname->getDescription();
142+
$row[$fieldname] = $item;
143+
}
135144
if (!empty($item) && strpos(strtolower($item), strtolower($clause)) !== false) {
136145
$searchFound = true;
137146
}

0 commit comments

Comments
 (0)