Custom forms - Post, redirect, get

(Gavin) #1

Matrix v5.5.6.6


I have a custom form where I have provided bodycopies for the Page Contents and Thank You pages.
The form works fine but if the thank you page is left open, a refresh will resubmit it (or I believe some browsers will refresh automatically).
Is there a best practice with Matrix for avoiding this ?
Traditional web development would usually require the use of a PRG pattern ( or a single use token.

Any help appreciated.


Did you ever work this out?

One thing I’ve just tried, which seems to work:

  1. Create a new Standard Page to act as the final thankyou destination
  2. Create a Redirect asset to the page asset above
  3. In the form Thank You bodycopy, insert a new nested content container, and choose the Redirect asset as the content

Note that Squiz it will give you the following warning

Warning: You are nesting in a form based asset. This can cause issues if caching is enabled. Please ensure caching settings are properly configured.

I’m relatively new to Squiz and am not at all familiar with caching. No clue what the appropriate caching settings should be, or if it even matters since we’re nesting on the Thankyou page and not the actual form.

(Gavin) #3

Hi, thanks for the reply.
In the end I think I did just this, except I probably just put a bit of JS in the Thank you page content.