bolt / bolt/boltforms

Feedback Messages inconsistencies with multiple forms

Open
#292 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
52
Forks
54
PR merge metrics
No merged PRs in 30d

Description

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 ?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.