mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 08:34:39 +00:00
mvc: group relation to something other than uuid if needed
This commit is contained in:
parent
091b075476
commit
fe571ac442
@ -94,26 +94,39 @@ class ModelRelationField extends BaseField
|
||||
|
||||
$modelObj = new $className;
|
||||
|
||||
$groupKey = isset($modelData['group']) ? $modelData['group'] : null;
|
||||
$displayKey = $modelData['display'];
|
||||
$groups = array();
|
||||
|
||||
foreach ($modelObj->getNodeByReference($modelData['items'])->__items as $node) {
|
||||
$displayKey = $modelData['display'];
|
||||
if (isset($node->getAttributes()["uuid"]) && $node->$displayKey != null) {
|
||||
// check for filters and apply if found
|
||||
$isMatched = true;
|
||||
if (isset($modelData['filters'])) {
|
||||
foreach ($modelData['filters'] as $filterKey => $filterValue) {
|
||||
$fieldData = $node->$filterKey;
|
||||
if (!preg_match($filterValue, $fieldData) && $fieldData != null) {
|
||||
$isMatched = false;
|
||||
break;
|
||||
}
|
||||
if (!isset($node->getAttributes()['uuid'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($node->$displayKey == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($modelData['filters'])) {
|
||||
foreach ($modelData['filters'] as $filterKey => $filterValue) {
|
||||
$fieldData = $node->$filterKey;
|
||||
if (!preg_match($filterValue, $fieldData) && $fieldData != null) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
if ($isMatched) {
|
||||
$uuid = $node->getAttributes()['uuid'];
|
||||
self::$internalOptionList[$this->internalCacheKey][$uuid] =
|
||||
$node->$displayKey->__toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($groupKey) && $node->$groupKey != null) {
|
||||
$group = $node->$groupKey->__toString();
|
||||
if (isset($groups[$group])) {
|
||||
continue;
|
||||
}
|
||||
$groups[$group] = 1;
|
||||
}
|
||||
|
||||
$uuid = $node->getAttributes()['uuid'];
|
||||
self::$internalOptionList[$this->internalCacheKey][$uuid] =
|
||||
$node->$displayKey->__toString();
|
||||
}
|
||||
|
||||
unset($modelObj);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user