i have a form in Symfony2 which i validate with ajax. This is all working, and i get back a json with "global" (for global errors) and "fields" (errors for each field in here) in my success statement of the ajax call:
{"global":[],"fields":{"fos_user_registration_form_username":"Please enter a
username","fos_user_registration_form_email":"Please enter an
email","fos_user_registration_form_plainPassword_first":"Please enter a password"}}
My question is: What is the best way to present these errors from "fields" in the view for each field? I rendered the view elements as the following when i validated the form without ajax:
<div class="form-group">
{{ form_label(form.xyz) }}
{{ form_widget(form.xyz) }}
{{ form_errors(form.xyz) }}
</div>
How can i inject now the errors from the "field" list of my json object into the appropriate
{{ form_errors(form.xyz) }}
?
I would love to hear your ideas and best practices.
Regards.