form/csrf: Set the csrf element decorators in the element not in the form

This commit is contained in:
Eric Lippmann 2014-09-19 12:57:53 +02:00
parent d10afa1f9b
commit 7eb51f6367
2 changed files with 2 additions and 3 deletions

View File

@ -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;

View File

@ -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());
}