Problem 1
I would like to create a registration form through an ajax view. Registration work - $form->isValid() . However, if the form fails registration, I need to return these errors via ajax.
if ($form->isValid()) { }else{ $errors = $form->getErrors();
$form->getErrors() returns an empty array, although the form has not been verified (in this case I am testing with a user name that is too short).
Problem 2
The second problem is that if the form is checked, but there is still an error. For example, a unique field in which someone is trying to represent the same value.
if ($form->isValid()) { $em = $this->getDoctrine()->getEntityManager(); $em->persist($form->getData()); $em->flush();
How can I catch this error and return it via json?
ed209 source share