[icinga-checkins] icinga.org: icingaweb2-module-director/feature/service-set-12891: DirectorObjectForm: do not set null values

git at icinga.org git at icinga.org
Wed Oct 26 01:12:35 CEST 2016


Module: icingaweb2-module-director
Branch: feature/service-set-12891
Commit: 1724a78da5bf44e38324b3c958e258211ce62557
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=1724a78da5bf44e38324b3c958e258211ce62557

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Oct 20 07:19:44 2016 +0000

DirectorObjectForm: do not set null values

---

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

diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php
index ae66161..117f765 100644
--- a/library/Director/Web/Form/DirectorObjectForm.php
+++ b/library/Director/Web/Form/DirectorObjectForm.php
@@ -236,7 +236,7 @@ abstract class DirectorObjectForm extends QuickForm
             unset($props['vars']);
         }
 
-        $this->setDefaults($props);
+        $this->setDefaults($this->removeNullProperties($props));
 
         if ($resolve) {
             $this->showInheritedProperties($object);
@@ -258,6 +258,18 @@ abstract class DirectorObjectForm extends QuickForm
         }
     }
 
+    protected function removeNullProperties($props)
+    {
+        $result = array();
+        foreach ($props as $k => $v) {
+            if ($v !== null && $v !== '') {
+                $result[$k] = $v;
+            }
+        }
+
+        return $result;
+    }
+
     protected function handleCustomVars($object, & $values)
     {
         if ($this->assertResolvedImports()) {



More information about the icinga-checkins mailing list