1

I need to validate field in a Symfony2 form. It's OK, but the error is always displayed next to the related fields.

In case of any error, I also would like to display a message at the form of the form which would say 'Carreful, one or more fields are not valid, please look below'.

Is it possible ? Should I use a custom constraint to add a violation ?

1 Answer 1

1

Supposing your form name is form, you can do the following in your view (twig)

{% if not form.vars.valid %}
   Carreful, one or more fields are not valid, please look below
{% endif %}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.