[icinga-checkins] icinga.org: icingaweb2-module-director/fiddle/mfrosch: ExtensibleSet: remove empty components

git at icinga.org git at icinga.org
Thu May 19 16:46:16 CEST 2016


Module: icingaweb2-module-director
Branch: fiddle/mfrosch
Commit: 8a6f7c0e384d6e4a27f2d6b0c7e5212af867b4f2
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=8a6f7c0e384d6e4a27f2d6b0c7e5212af867b4f2

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu May 19 15:02:30 2016 +0200

ExtensibleSet: remove empty components

fixes #11360

---

 library/Director/Web/Form/Element/ExtensibleSet.php |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/library/Director/Web/Form/Element/ExtensibleSet.php b/library/Director/Web/Form/Element/ExtensibleSet.php
index 3b4ec31..d17d978 100644
--- a/library/Director/Web/Form/Element/ExtensibleSet.php
+++ b/library/Director/Web/Form/Element/ExtensibleSet.php
@@ -15,6 +15,21 @@ class ExtensibleSet extends FormElement
 
    // private $multiOptions;
 
+    public function getValue()
+    {
+        $value = parent::getValue();
+        if (! is_array($value)) {
+            $value = array($value);
+        }
+        $value = array_filter($value, 'strlen');
+
+        if (empty($value)) {
+            return null;
+        }
+
+        return $value;
+    }
+
     public function isValid($value, $context = null)
     {
         if ($value === null) {



More information about the icinga-checkins mailing list