Last active
August 29, 2015 14:14
-
-
Save silenzium/87313f71a580510c48fb to your computer and use it in GitHub Desktop.
ZF2 helper function to remove all errors in a form or fieldset recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Zend\Form\FieldsetInterface; | |
/** | |
* Remove all errors in a form recursively | |
* pass a form or a fieldset as parameter | |
* | |
* @param FieldsetInterface $form | |
* @return void | |
*/ | |
public function clearFormErrors(FieldsetInterface $form) | |
{ | |
$arr = array(); | |
foreach($form->getElements() as $element) { | |
$element->setMessages($arr); | |
} | |
foreach($form->getFieldsets() as $fieldset) { | |
$this->clearFormErrors($fieldset); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment