can you please help me understand how to customize error messages in a form with Symfony2? I want to change the HTML layout, adding div, class, etc...
Reading the guide, it gives a piece of code to put in a file called fields_errors.html.twig
but it doesn't tells where to put this file and if some extra configuration is needed.
Can somebody help me?
In symfony3 first call de theme form in config.yml
Twig error.html.twig example
You can customise all your error messages at once in your template:
Or individually (if your field is title for example)
You have to put the template in
Resourses/views/
folder of your bundle. For example,And then in your form page template,
For more option and implementation reference check form theme cookbook entry and default field layout implementation