-
-
Save WishCow/5101428 to your computer and use it in GitHub Desktop.
One of the new symfony releases (probably 2.1) broke the previous gist, because $form->getErrors() now returns a sequentially indexed array, instead of a fieldname => errormsg one.
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
<?php | |
private function getErrorMessages(\Symfony\Component\Form\Form $form) { | |
$errors = array(); | |
if ($form->hasChildren()) { | |
foreach ($form->getChildren() as $child) { | |
if (!$child->isValid()) { | |
$errors[$child->getName()] = $this->getFormErrors($child); | |
} | |
} | |
} else { | |
foreach ($form->getErrors() as $key => $error) { | |
$errors[] = $error->getMessage(); | |
} | |
} | |
return $errors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On line 9 there should be
getErrorMessages
thanks for gist