Issues with Multi-Page Forms in Formie Plugin with Varnish Cache #1903
Replies: 2 comments 12 replies
-
Is this a Page Reload form, or an Ajax one? If the former, that's going to be an issue, as when the page reloads it's not typically going to hit your server to even determine what the current page is on. Hence the page will be cached and you'll just see the same page. If this is an Ajax-based form, that shouldn't be the behaviour you see, as the page-changing mechanism is via JS, and any calls to the server will still use sessions to determine the current page, but it won't be refreshing the page. I wouldn't have thought Varnish be caching the requests to submit the form? If an Ajax form, you should be able to check the response data, and see the We've toyed with some configurable options for how to handle multi-page forms (I believe plugins like Freeform have something like this), but haven't come up with some solid proposals that work in the variety of different front-ends out there. |
Beta Was this translation helpful? Give feedback.
-
We’ve ran info this problem as well (Also on ajax forms). The main problem seems to be static cached pages don’t have sessions. Formie is then lost to which is the currentpage and the nextpage. It’s a bit hacky, but I worked around this by manually validate pages only on the front-end and submit the whole form only at the last page by adding hidden input with the name submissionIsComplete (could be a bit different, trying to remember it on my phone) with a true value . The trick is to call Craft::$app->session->open() on beforesubmit and beforesave. @engram-design Statically caching pages is pretty common. Is manually opening the session the best solution, or is it a bug where the currentPage and nextPage should work nontheless? |
Beta Was this translation helpful? Give feedback.
-
Hi there,
I'm experiencing an issue with the Formie plugin in Craft CMS on my website, which is set up with Varnish cache. The problem specifically occurs with multi-page forms. When the page is cached, the "Next" button does not work correctly.
Here is a more detailed description of the problem:
Environment Details:
Craft CMS Version: 4.8.10
Formie Plugin Version: 2.1.12
Varnish Version: vcl 4.0
Problem Description:
Single-page forms work as expected.
Multi-page forms exhibit issues when the page is cached by Varnish. Specifically, the "Next" button does not function properly.
Investigation and Findings:
Initially, I suspected that the responses were being cached, causing the issue. However, after further investigation, I found that this is not the case.
The issue appears to be related to the _returnJsonResponse() function, which utilizes getCurrentPage() located in elements/Form.php.
The current page is determined by the following line of code: $pageId = Session::get($this->_getSessionKey('pageId'));
It seems that this problem arises because Varnish does not work with sessions.
Question:
How can I work around this issue given that Varnish does not support sessions?
Is there an alternative way to handle multi-page form navigation that is compatible with Varnish cache?
Any guidance or suggestions would be greatly appreciated!
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions