Skip to content

[Form] How to display a message introducing that submission failed (due to errors) #685

Closed
@brikou

Description

@brikou

It could be nice to explain how to display a message introducting that submission failed due to some filling errors.

To detect if form contains errors I check the used method (if POST then form is not valid)

{% if app.request.method == "POST" %} {# there must be a better way #}
<p>Your form contains errors, please check it again.</p>
{% endif %}

<form action="{{ path('myEntity_create') }}" method="post" {{ form_enctype(form) }}>
    {{ form_widget(form) }}

    <p><button type="submit">Create</button></p>
</form>

I'm sure (or I wish) there is a better way to do it but I don't want to introduce a new variable from the controller...

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionableClear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions