[icinga-checkins] icinga.org: icingaweb2/feature/add-to-dashboard-4537: Disable partial validation of forms by default

git at icinga.org git at icinga.org
Tue Nov 18 17:03:10 CET 2014


Module: icingaweb2
Branch: feature/add-to-dashboard-4537
Commit: 760bf1a020f221699dc7b19c4d7fc0eb99cc3f94
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=760bf1a020f221699dc7b19c4d7fc0eb99cc3f94

Author: Johannes Meyer <johannes.meyer at netways.de>
Date:   Tue Nov 18 15:04:11 2014 +0100

Disable partial validation of forms by default

---

 library/Icinga/Web/Form.php |   34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php
index 1627cfe..75357e2 100644
--- a/library/Icinga/Web/Form.php
+++ b/library/Icinga/Web/Form.php
@@ -102,6 +102,13 @@ class Form extends Zend_Form
     protected $uidElementName = 'formUID';
 
     /**
+     * Whether the form should validate the sent data when being automatically submitted
+     *
+     * @var bool
+     */
+    protected $validatePartial = false;
+
+    /**
      * Default element decorators
      *
      * @var array
@@ -334,6 +341,29 @@ class Form extends Zend_Form
     }
 
     /**
+     * Set whether this form should validate the sent data when being automatically submitted
+     *
+     * @param   bool    $state
+     *
+     * @return  self
+     */
+    public function setValidatePartial($state)
+    {
+        $this->validatePartial = $state;
+        return $this;
+    }
+
+    /**
+     * Return whether this form should validate the sent data when being automatically submitted
+     *
+     * @return  bool
+     */
+    public function getValidatePartial()
+    {
+        return $this->validatePartial;
+    }
+
+    /**
      * Create this form
      *
      * @param   array   $formData   The data sent by the user
@@ -580,8 +610,8 @@ class Form extends Zend_Form
                         || ($this->onSuccess === null && false !== $this->onSuccess()))) {
                     $this->getResponse()->redirectAndExit($this->getRedirectUrl());
                 }
-            } else {
-                // The form can't be processed but we want to show validation errors though
+            } elseif ($this->getValidatePartial()) {
+                // The form can't be processed but we may want to show validation errors though
                 $this->isValidPartial($formData);
             }
         } else {



More information about the icinga-checkins mailing list