From 760bf1a020f221699dc7b19c4d7fc0eb99cc3f94 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 18 Nov 2014 15:04:11 +0100 Subject: [PATCH] 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 1627cfe48..75357e2fb 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -101,6 +101,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 * @@ -333,6 +340,29 @@ class Form extends Zend_Form return $this->uidElementName; } + /** + * 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 * @@ -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 {