-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
DXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)Form
Description
Every time when i need to return form errors to json I need to transform manually errors in my controller like:
/** @var array $errors */
$errors = array();
/** @var FormError $error */
foreach($form->getErrors(true) as $error)
{
$errors[] = array('message'=>$error->getMessage());
}
$response = new JsonResponse();
$response->setData(array(
'errors' => $errors
));
but with this simple implementation we can do:
/** @var JsonResponse $response */
$response = new JsonResponse();
$response->setData(array(
'form'=>array(
'errors' => $form->getErrors(true)
)
));
I do not see if this implementation can have any adverse side effect.
conradkleinespel
Metadata
Metadata
Assignees
Labels
DXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)Form