Skip to content

Instantly share code, notes, and snippets.

@simshaun
Last active October 7, 2016 19:14
Show Gist options
  • Save simshaun/4e12214b38975921733eed0475333da2 to your computer and use it in GitHub Desktop.
Save simshaun/4e12214b38975921733eed0475333da2 to your computer and use it in GitHub Desktop.
Symfony2 get form errors as array. May not work properly with nested forms & duplicate keys
$errors = [];
foreach ($form->getErrors(true, true) as $error) {
$errors[$error->getOrigin()->getName()] = $error->getMessage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment