From cc6183125832b47c8d7d4775e616d6c9212ee89b Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 13 Oct 2016 16:37:49 +0200 Subject: [PATCH 1/2] DirectorObjectForm: Allow form to select if imports are required refs #12920 --- library/Director/Web/Form/DirectorObjectForm.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index d6478d64..c6275076 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -14,6 +14,7 @@ abstract class DirectorObjectForm extends QuickForm { protected $db; + /** @var IcingaObject */ protected $object; protected $objectName; @@ -1144,7 +1145,7 @@ abstract class DirectorObjectForm extends QuickForm return $this; } - protected function addImportsElement() + protected function addImportsElement($required = null) { $enum = $this->enumAllowedTemplates(); if (empty($enum)) { @@ -1158,7 +1159,7 @@ abstract class DirectorObjectForm extends QuickForm . ' matters when importing properties from multiple templates: last one' . ' wins' ), - 'required' => !$this->isTemplate(), + 'required' => ($required !== null ? $required : !$this->isTemplate()), 'multiOptions' => $this->optionallyAddFromEnum($enum), 'sorted' => true, 'class' => 'autosubmit' From 255a02cf3638667cb2c54aef789b46736edea110 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 13 Oct 2016 16:39:55 +0200 Subject: [PATCH 2/2] IcingaEndpointForm: Render imports input only when set We don't need Endpoint templates in GUI. refs #12920 --- application/forms/IcingaEndpointForm.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/application/forms/IcingaEndpointForm.php b/application/forms/IcingaEndpointForm.php index a20b4a9e..1c08cb4a 100644 --- a/application/forms/IcingaEndpointForm.php +++ b/application/forms/IcingaEndpointForm.php @@ -47,8 +47,14 @@ class IcingaEndpointForm extends DirectorObjectForm 'multiOptions' => $this->optionalEnum($this->db->enumApiUsers()) )); - $this->addZoneElement() - ->addImportsElement(); + $this->addZoneElement(); + + if ($this->object->hasBeenLoadedFromDb()) { + $imports = $this->object->get('imports'); + if ($imports !== null && count($imports) > 0) { + $this->addImportsElement(false); + } + } $this->setButtons(); }