From 4efa575201ddc620bda35dc3d76b445003201a53 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Fri, 30 Nov 2018 19:18:28 +0200 Subject: [PATCH] FieldManager: bug fixes --- application/Espo/Core/Utils/FieldManager.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/application/Espo/Core/Utils/FieldManager.php b/application/Espo/Core/Utils/FieldManager.php index fb446fbf2a..1604d3e322 100644 --- a/application/Espo/Core/Utils/FieldManager.php +++ b/application/Espo/Core/Utils/FieldManager.php @@ -424,7 +424,7 @@ class FieldManager protected function getCustomFieldDefs($scope, $name) { - $customDefs = $this->getMetadata()->getCustom('entityDefs', $scope); + $customDefs = $this->getMetadata()->getCustom('entityDefs', $scope, (object) []); if (isset($customDefs->fields->$name)) { return (array) $customDefs->fields->$name; @@ -433,16 +433,24 @@ class FieldManager protected function saveCustomdDefs($scope, $newDefs) { - $customDefs = $this->getMetadata()->getCustom('entityDefs', $scope); + $customDefs = $this->getMetadata()->getCustom('entityDefs', $scope, (object) []); if (isset($newDefs->fields)) { foreach ($newDefs->fields as $name => $defs) { + if (!isset($customDefs->fields)) { + $customDefs->fields = new \StdClass(); + } + $customDefs->fields->$name = $defs; } } if (isset($newDefs->links)) { foreach ($newDefs->links as $name => $defs) { + if (!isset($customDefs->links)) { + $customDefs->links = new \StdClass(); + } + $customDefs->links->$name = $defs; } }