From e1329058db1bf0dd2554b79e67b5fb0ea72dd441 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 27 Aug 2014 13:14:40 +0200 Subject: [PATCH] Do not hard code the name of the form identification element Like the csrf element name the form identification element name should be publicly accessible as well. refs #5525 --- 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 90733c13b..eb8fd7386 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -60,6 +60,13 @@ class Form extends Zend_Form */ protected $tokenElementName = 'CSRFToken'; + /** + * Name of the form identification element + * + * @var string + */ + protected $uidElementName = 'formUID'; + /** * Set the label to use for the standard submit button * @@ -185,6 +192,29 @@ class Form extends Zend_Form return $this->tokenElementName; } + /** + * Set the name to use for the form identification element + * + * @param string $name The name to set + * + * @return self + */ + public function setUidElementName($name) + { + $this->uidElementName = $name; + return $this; + } + + /** + * Return the name of the form identification element + * + * @return string + */ + public function getUidElementName() + { + return $this->uidElementName; + } + /** * Create this form * @@ -317,7 +347,7 @@ class Form extends Zend_Form { $this->addElement( 'hidden', - 'form_uid', + $this->uidElementName, array( 'ignore' => true, 'value' => $this->getName() @@ -416,7 +446,7 @@ class Form extends Zend_Form */ public function wasSent(array $formData) { - return isset($formData['form_uid']) && $formData['form_uid'] === $this->getName(); + return isset($formData[$this->uidElementName]) && $formData[$this->uidElementName] === $this->getName(); } /**