Skip to content

Feedback Messages inconsistencies with multiple forms #292

@dadaxr

Description

@dadaxr

The way feedback messages are coded prevent them to be used when there are multiple (bolt) forms on a page.

According to the following use case :
There is a first form on my page : the contact form.
Then a second form bellow, in the footer : the newsletter form.

If I correctly fill the 2nd form, and submit it, the feedback messages are correctly set in the code ... until the internal lifecycle event listener is triggered : When the src/extensions/vendor/bolt/boltforms/src/Submission/Processor/Redirect.php "process" function is called, the behavior is to send a redirect response (to transform the POST request in a GET request).

The problem lied here : when the new redirect request is handled, the forms are built again, starting with the first form (contact form), and the flash messages which were initially set by the 2nd form are now retrieved for the first form... (everything happen in the src/extensions/vendor/bolt/boltforms/src/Factory/FormContext.php file within the "build" function ).

A possible workarround could be to tied feedback messages to their respective form (using the form name), instead of globaly. We could then have the following structure :

[
"contact_form:debug" : [...],
"contact_form:error" : [...],
"contact_form:info" : [...],
"newsletter_form:debug" : [...],
"newsletter_form:error" : [...],
"newsletter_form:info" : [...],
...
]

the PR should be quite easy to do ... but it's a breaking change (it has an impact on templates).

what do you think ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions