From b18cf4f80d1fd040d1f6f3b67d91bc90739e92d1 Mon Sep 17 00:00:00 2001 From: raviks789 Date: Tue, 14 Jan 2025 17:46:43 +0100 Subject: [PATCH] Fix editing of custom variables for multi-selected objects --- application/forms/IcingaMultiEditForm.php | 5 +---- library/Director/Web/Form/IcingaObjectFieldLoader.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/application/forms/IcingaMultiEditForm.php b/application/forms/IcingaMultiEditForm.php index 4849d467..7f0c0d11 100644 --- a/application/forms/IcingaMultiEditForm.php +++ b/application/forms/IcingaMultiEditForm.php @@ -51,6 +51,7 @@ class IcingaMultiEditForm extends DirectorObjectForm $loader = new IcingaObjectFieldLoader($object); $loader->prepareElements($this); $loader->addFieldsToForm($this); + $this->varNameMap = $loader->getNameMap(); if ($form = $this->relatedForm) { if ($form instanceof DirectorObjectForm) { @@ -237,10 +238,6 @@ class IcingaMultiEditForm extends DirectorObjectForm $this->removeElement($key); $label = $element->getLabel(); - if ($this->isCustomVar($key)) { - $this->varNameMap[$key] = $label; - } - $group = $this->getDisplayGroupForElement($element); $description = $element->getDescription(); diff --git a/library/Director/Web/Form/IcingaObjectFieldLoader.php b/library/Director/Web/Form/IcingaObjectFieldLoader.php index 83b1aa6d..cf58b9eb 100644 --- a/library/Director/Web/Form/IcingaObjectFieldLoader.php +++ b/library/Director/Web/Form/IcingaObjectFieldLoader.php @@ -60,6 +60,16 @@ class IcingaObjectFieldLoader return $this; } + /** + * Get element names to variable names map (Example: ['elName' => 'varName']) + * + * @return array + */ + public function getNameMap(): array + { + return $this->nameMap; + } + public function loadFieldsForMultipleObjects($objects) { $fields = array();