how can i show customised form validation error message in symfony2

Rajesh Vasani picture Rajesh Vasani · Mar 2, 2012 · Viewed 24k times · Source

This is the link to my form window

Can anybody suggest how to customize the error messages in my form window like - 'This value is not valid', 'Passwords do not match' to appear like a pop up error message for empty field?

Answer

Mun Mun Das picture Mun Mun Das · Mar 2, 2012

Validation error messages can be customized at your bundles validation.yml file. I have added an example.

# src/Vendor/YourBundleName/Resources/config/validation.yml
Vendor\YourBundleName\Entity\YourModel:
    properties:
        email:
            - Email:
                message: The email you entered is not a valid email.
            - NotBlank
                message: Please enter email.

Please read validation doc section and validation constraint reference carefully.