Index: documentation/manual/en/module_specs/Zend_Form-StandardElements.xml =================================================================== --- documentation/manual/en/module_specs/Zend_Form-StandardElements.xml (revision 24514) +++ documentation/manual/en/module_specs/Zend_Form-StandardElements.xml (working copy) @@ -522,6 +522,37 @@ The 'formHidden' view helper is used to render the element in the form. + + + Testing forms containing Zend_Form_Element_Hash + + When unit testing a form containing a Zend_Form_Element_Hash + it is necessary to call initCsrfToken and + initCsrfValidator before attempting to + validate the form. The hash value of the Zend_Form_Element_Hash + element must also be injected into the array of values passed as the + argument to Zend_Form::isValid + + + Simple example of testing a CSRF-protected form + addElement(new Zend_Form_Element_Hash('csrf')); + + $csrf = $form->getElement('csrf'); + $csrf->initCsrfToken(); + $csrf->initCsrfValidator(); + + $this->assertTrue($form->isValid(array( + 'csrf' => $csrf->getHash() + ))); +}]]> + + + +