symfony: How to place the screen on the form error?

Some of my web pages are very long and have a form at the bottom of the page. Upon sending a form that fails validation, I am brought back to the top of the page, which is not very user friendly.

I would want to find a way to, after an error, place the scroll on the error, or at the top of the form at least.

Does anyone know of a way to control this?

I did, using javascript:

{% if not form.vars.valid %}
    window.location.hash = 'form';
{% endif %}

I don”t think it is very clean. Do you know of another way?


Source: forms

Leave a Reply