Last active
December 15, 2015 20:28
FormErrorResponse for handling AJAX submitted forms
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 | |
protected function getFormErrors(Form $form) { | |
$errors = array(); | |
$children = $form->all(); | |
if (count($children)) { | |
foreach ($children 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