Skip to content

Instantly share code, notes, and snippets.

@richsage
Created March 5, 2012 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richsage/1978182 to your computer and use it in GitHub Desktop.
Save richsage/1978182 to your computer and use it in GitHub Desktop.
errors lol
/**
* Gets all field errors
*
* @param $form
* @return array
*/
protected function getAllErrors($form)
{
$errors = array();
foreach ($form->getErrors() as $key => $error) {
$errors[] = strtr($error->getMessageTemplate(), $error->getMessageParameters());
}
if ($form->hasChildren()) {
foreach ($form->getChildren() as $child) {
if (!$child->isValid()) {
$errors[$child->getName()] = $this->getAllErrors($child);
}
}
}
return $errors;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment