diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index f0695242e..dde9db41c 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -480,9 +480,7 @@ class Form extends Zend_Form public function addCsrfCounterMeasure() { if (false === $this->tokenDisabled && $this->getElement($this->tokenElementName) === null) { - $element = new CsrfCounterMeasure($this->tokenElementName); - $element->setDecorators(array('ViewHelper')); - $this->addElement($element); + $this->addElement(new CsrfCounterMeasure($this->tokenElementName)); } return $this; diff --git a/library/Icinga/Web/Form/Element/CsrfCounterMeasure.php b/library/Icinga/Web/Form/Element/CsrfCounterMeasure.php index 4d788f9d3..722b1d323 100644 --- a/library/Icinga/Web/Form/Element/CsrfCounterMeasure.php +++ b/library/Icinga/Web/Form/Element/CsrfCounterMeasure.php @@ -29,6 +29,7 @@ class CsrfCounterMeasure extends Zend_Form_Element_Xhtml { $this->setRequired(true); // Not requiring this element would not make any sense $this->setIgnore(true); // We do not want this element's value being retrieved by Form::getValues() + $this->setDecorators(array('ViewHelper')); $this->setValue($this->generateCsrfToken()); }