Skip to content

Add cookbook chapter on error_bubbling and dealing with form errors in twig #6145

Closed
@webdevilopers

Description

@webdevilopers

@weaverryan from @KnpLabs posted a nice article here:
https://knpuniversity.com/blog/symfony-debugging-form-errors

Originally I came from the following issue: symfony/symfony#17363

The described issue caused a strange effect in which non mapped field errors were linked to the parent form - the same thing that would have happened if you turned error_bubbling to true.

Since this I was able to catch the errors from the form.vars array in my template:

{% if form.vars.errors|length > 0 %}

After i solved the issue the errors were correctly removed from the bubble and attached to the assigned field. My twig condition would no longer work. I had to change it:

{% if not form.vars.valid %}

I've seen a lot of questions on SO on this e.g.:

Actually I havn't found any chapter that explains what error_bubbling is in the first place.
Most of the times it is described directly inside a form field type or collection.

I think the cookbook could really be improved with this. What do you think?

Activity

carsonbot

carsonbot commented on Dec 18, 2020

@carsonbot
Collaborator

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

carsonbot

carsonbot commented on Jan 1, 2021

@carsonbot
Collaborator

Friendly ping? Should this still be open? I will close if I don't hear anything.

webdevilopers

webdevilopers commented on Jan 4, 2021

@webdevilopers
Author

I'm no longer working with the Form component. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @javiereguiluz@xabbuh@webdevilopers@carsonbot

        Issue actions

          Add cookbook chapter on error_bubbling and dealing with form errors in twig · Issue #6145 · symfony/symfony-docs