[icinga-checkins] icinga.org: icingaweb2/bugfix/ group_name_attribute-should-be-sAMAccountName-by-default-12295: Form: Return values as null if element has "ignore" and "preserveDefault"

git at icinga.org git at icinga.org
Wed Jan 11 11:04:15 CET 2017


Module: icingaweb2
Branch: bugfix/group_name_attribute-should-be-sAMAccountName-by-default-12295
Commit: 277f4b0ddf7d0f495e463bcff87eb6cbd65419a5
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=277f4b0ddf7d0f495e463bcff87eb6cbd65419a5

Author: Noah Hilverling <noah.hilverling at netways.de>
Date:   Mon Jan  9 17:03:53 2017 +0100

Form: Return values as null if element has "ignore" and "preserveDefault"

refs #12295

---

 library/Icinga/Web/Form.php |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php
index 9660fbf..cf56149 100644
--- a/library/Icinga/Web/Form.php
+++ b/library/Icinga/Web/Form.php
@@ -1276,6 +1276,30 @@ class Form extends Zend_Form
         return parent::isValid($formData);
     }
 
+    public function getValues($suppressArrayNotation = false)
+    {
+        $values = parent::getValues($suppressArrayNotation);
+        $eBelongTo = null;
+
+        if ($this->isArray()) {
+            $eBelongTo = $this->getElementsBelongTo();
+        }
+
+        foreach ($this->getElements() as $key => $element) {
+            if ($element->getIgnore() && $element->getDecorator('preserveDefault')) {
+                if (($belongsTo = $element->getBelongsTo()) !== $eBelongTo) {
+                    if ('' !== (string)$belongsTo) {
+                        $key = $belongsTo . '[' . $key . ']';
+                    }
+                }
+                $merge = $this->_attachToArray(null, $key);
+                $values = $this->_array_replace_recursive($values, $merge);
+            }
+        }
+
+        return $values;
+    }
+
     /**
      * Remove all elements of this form
      *



More information about the icinga-checkins mailing list