Advertisement
Guest User

Untitled

a guest
May 30th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. <?php
  2. // put this in your controller
  3.  
  4. protected function getErrorsFromForm(FormInterface $form)
  5. {
  6. $errors = array();
  7. foreach ($form->getErrors() as $error) {
  8. $errors[] = $error->getMessage();
  9. }
  10.  
  11. foreach ($form->all() as $childForm) {
  12. if ($childForm instanceof FormInterface) {
  13. if ($childErrors = $this->getErrorsFromForm($childForm)) {
  14. $errors[$childForm->getName()] = $childErrors;
  15. }
  16. }
  17. }
  18.  
  19. return $errors;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement