I validated my form through AJAX CALL but can't retrieve "error messages".
Here is what i put :
$newRdvForm = $this->createForm(new RdvType());
$newRdvForm->handleRequest($request);
if ($newRdvForm->isValid()) {
// set of instructions to be performed when the form is valid
}
else {
$errors= array();
foreach ($newRdvForm->getErrors() as $key => $error) {
$errors[$key] = $error->getMessage();
}
$response = new Response(json_encode($errors));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
I used symfony 2.7. The above code doesn't retrieve the error messages.