[icinga-checkins] icinga.org: icingaweb2-module-director/master: DirectorObjectForm: persist the field loader

git at icinga.org git at icinga.org
Thu Oct 27 18:37:05 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: f87e80989dc9f43c68058ab9c58028495b1dec98
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=f87e80989dc9f43c68058ab9c58028495b1dec98

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Oct 20 04:26:37 2016 +0000

DirectorObjectForm: persist the field loader

---

 library/Director/Web/Form/DirectorObjectForm.php |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php
index 329127c..ae66161 100644
--- a/library/Director/Web/Form/DirectorObjectForm.php
+++ b/library/Director/Web/Form/DirectorObjectForm.php
@@ -33,6 +33,8 @@ abstract class DirectorObjectForm extends QuickForm
 
     protected $preferredObjectType;
 
+    protected $fieldLoader;
+
     private $allowsExperimental;
 
     private $api;
@@ -259,12 +261,23 @@ abstract class DirectorObjectForm extends QuickForm
     protected function handleCustomVars($object, & $values)
     {
         if ($this->assertResolvedImports()) {
-            $loader = new IcingaObjectFieldLoader($object);
+            $loader = $this->fieldLoader($object);
             $loader->addFieldsToForm($this);
             if ($values) {
                 $loader->setValues($values, 'var_');
             }
         }
+
+        return $this;
+    }
+
+    protected function fieldLoader($object)
+    {
+        if ($this->fieldLoader === null) {
+            $this->fieldLoader = new IcingaObjectFieldLoader($object);
+        }
+
+        return $this->fieldLoader;
     }
 
     protected function isNew()



More information about the icinga-checkins mailing list