mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 16:44:39 +00:00
Services / Unbound + core MVC - extend ModelRelationField to show combined descriptions using vsprintf() and implement hostname.domain in new unbound alias popup. closes https://github.com/opnsense/core/issues/5694
This commit is contained in:
parent
ff11cde38e
commit
714eca2b18
@ -95,13 +95,22 @@ class ModelRelationField extends BaseListField
|
||||
}
|
||||
|
||||
$groupKey = isset($modelData['group']) ? $modelData['group'] : null;
|
||||
$displayKey = $modelData['display'];
|
||||
$displayKeys = explode(',', $modelData['display']);
|
||||
$displayFormat = !empty($modelData['display_format']) ? $modelData['display_format'] : "%s";
|
||||
$groups = array();
|
||||
|
||||
$searchItems = $modelObj->getNodeByReference($modelData['items']);
|
||||
if (!empty($searchItems)) {
|
||||
foreach ($modelObj->getNodeByReference($modelData['items'])->iterateItems() as $node) {
|
||||
if (!isset($node->getAttributes()['uuid']) || $node->$displayKey == null) {
|
||||
$descriptions = [];
|
||||
foreach ($displayKeys as $displayKey) {
|
||||
if ($node->$displayKey != null) {
|
||||
$descriptions[] = (string)$node->$displayKey;
|
||||
} else {
|
||||
$descriptions[] = "";
|
||||
}
|
||||
}
|
||||
if (!isset($node->getAttributes()['uuid'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -126,8 +135,9 @@ class ModelRelationField extends BaseListField
|
||||
}
|
||||
|
||||
$uuid = $node->getAttributes()['uuid'];
|
||||
self::$internalCacheOptionList[$this->internalCacheKey][$uuid] =
|
||||
(string)$node->$displayKey;
|
||||
self::$internalCacheOptionList[$this->internalCacheKey][$uuid] = vsprintf(
|
||||
$displayFormat, $descriptions
|
||||
);
|
||||
}
|
||||
}
|
||||
unset($modelObj);
|
||||
|
||||
@ -184,7 +184,8 @@
|
||||
<host>
|
||||
<source>OPNsense.Unbound.Unbound</source>
|
||||
<items>hosts.host</items>
|
||||
<display>domain</display>
|
||||
<display>hostname,domain</display>
|
||||
<display_format>%s.%s</display_format>
|
||||
</host>
|
||||
</Model>
|
||||
<Required>Y</Required>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user