-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feedback Messages inconsistencies with multiple forms #292
Comments
As far as I remember the feedback messages can be overridden in the configuration for each form, similar to the redirect. So you should be able to override the messages in the feedback form like this: newsletter_form:
notification:
enabled: true
debug: false
feedback:
error: "there was an error in the newsletter form"
success: "The newsletter form was successfully submitted"
fields:
name:
type: text |
Indeed you can defined feedback message by form in the config file. But the problem is not setting the feedback message. The problem is displaying the correctly defined message next to the right form in the template. In short : with the current behavior, every form are fetching feedback message from the same variable in session. In theory It should not break because we submit only one form at once ... except when there is a redirect (which is the default case) which break that logic. |
I can illustrate the problem like that : given the following code :
after the first page load it display something like that :
Then if I submit the 2nd form , it will display :
Instead of :
|
If you can spare the time to do a PR, that'd be welcome. I don't mind a major version bump for this! :-) |
Hi! |
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 :
the PR should be quite easy to do ... but it's a breaking change (it has an impact on templates).
what do you think ?
The text was updated successfully, but these errors were encountered: