verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
94 stars 72 forks source link

Issue with formie and blitz #2020

Open Megafry opened 1 month ago

Megafry commented 1 month ago

Describe the bug

Hi We have found an issue with formie and blitz I added the following code to my project to prevent blitz from caching user data: {% do craft.formie.setCurrentSubmission(form, null) %}

If the user reloads the page to start over without completing his first submission and clicks on next, he ends up on the next page from his old submission. (Check steps to reproduce)

Can you add this to #2001

Best regards

Steps to reproduce

  1. Install blitz
  2. Enable it
  3. Import this form formie-contact.json
  4. Add the form to a page
  5. Add this code to ensure no submission data will be rendered and cached by blitz {% do craft.formie.setCurrentSubmission(form, null) %}
  6. Ensure the page is cached (check for comment Cached by Blitz ...)
  7. Open the page in a private browser
  8. Click next to go to page 2
  9. Reload the page, you are back to page 1 and the form is empty as expected
  10. Click next, you are now on page 3

Form settings

Craft CMS version

4.11.1

Plugin version

2.1.24

Multi-site?

No

Additional context

Blitz: 4.22.0

engram-design commented 1 month ago

This is a little tricky with Blitz, as if you have server rewrites setup, it's never going to even hit Craft/Formie to run this Twig code. I'm not sure if you have that enabled yet.

Otherwise, this is going to behave as I'd expect with a static cache. If the entire page is cached, this Twig code isn't going to run every time.

But as for the session data, that's not going to be cached, being a POST request, so it's likely to get out of sync.

As you mentioned, with this issue we're going to need to come up with an all-encompassing way to handle statically-cached sites, including changing session-handling behaviour.

Megafry commented 1 month ago

Thanks for your feedback I hope that a solution can be found.