Jump to main content Jump to doc navigation

What is FormItRetriever?

FormItRetriever is an assistance snippet for FormIt that will grab the data of a user's last form submission via FormIt. This is useful for "Thank You" pages where a user is sent after submitting a form.

Usage

Simply add this Snippet to whatever page you are redirecting from using FormIt's &redirectTo property, and set &store=1 in the FormIt call:

[[!FormItRetriever]]

And then display your form data with placeholders relating to the names of your form fields like such:

<p>Thanks [[!+fi.name]] for submitting. An email will be sent to you at [[!+fi.email]].</p>

Remember to set &store=1 in your FormIt call, so FormIt knows to store the value.

Make sure to call the placeholders uncached. This data changes on every request, so therefore the placeholders need to change every request too.

FormItRetriever Properties

FormItRetriever comes with some default properties you can override. They are:

Name Description Default
placeholderPrefix A string to prefix all placeholders for form fields that will be set by this Snippet. fi.
redirectToOnNotFound If the data is not found and if this is set, redirect to the Resource with this ID.
eraseOnLoad If true, will erase the stored form data on load. Strongly recommended to leave to false unless you only want the data to load once.
storeLocation Where to get the form data from. Should be equal to the storeLocation property of your FormIt snippet call. Possible values are 'cache' and 'session'. Defaults to 'cache'. cache

Example

Submit a form with auto-response and anti-spam protection, then redirect to a Thank You page where it loads the last form submission, and if it's not found, redirects to the resource with ID 444.

On your form page:

[[!FormIt?
    &submitVar=`go`
    &hooks=`spam,FormItAutoResponder,redirect`
    &emailTo=`[email protected]`
    &store=`1`
    &redirectTo=`123`
]]
<form action="[[~[[*id]]]]" method="post">
    <input type="hidden" name="nospam" value="" />
    <label for="name">Name: [[!+fi.error.name]]</label>
    <input type="text" name="name:required" id="name" value="[[!+fi.name]]" />
    <label for="email">Email: [[!+fi.error.email]]</label>
    <input type="text" name="email:email:required" id="email" value="[[!+fi.email]]" />
    <label for="message">Message: [[!+fi.error.message]]</label>
    <textarea name="message:stripTags" id="message" cols="55" rows="7">[[!+fi.message]]</textarea>
    <br />
    <input type="submit" name="go" value="Send Contact Inquiry" />
</form>

On your Thank You page (Resource ID 123):

[[!FormItRetriever? &redirectToOnNotFound=`444`]]
<p>Thanks [[!+fi.name]] for submitting. An auto-response email will be sent to you at [[!+fi.email]]. Here's a copy of your message:</p>
[[!+fi.message]]

See Also

  1. FormIt.Hooks
    1. FormIt.Hooks.email
    2. FormIt.Hooks.FormItAutoResponder
    3. FormIt.Hooks.math
    4. FormIt.Hooks.recaptcha
    5. FormIt.Hooks.redirect
    6. FormIt.Hooks.spam
    7. FormIt.Hooks.FormItSaveForm
  2. FormIt.Validators
  3. FormIt.FormItRetriever
  4. FormIt.Tutorials and Examples
    1. FormIt.Examples.Custom Hook
    2. FormIt.Examples.Simple Contact Page
    3. FormIt.Handling Selects, Checkboxes and Radios
    4. FormIt.Using a Blank NoSpam Field
  5. FormIt.FormItCountryOptions
  6. FormIt.FormItStateOptions

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Digital Penguin
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • Following Sea
  • Anton Tarasov
  • eydolan
  • Raffy
  • Lefthandmedia
  • Murray Wood
  • Snow Creative
  • Nick Clark
  • Helen
  • JT Skaggs
  • krisznet
  • YJ
  • Yanni
  • Richard

Budget

$366 per month—let's make that $500!

Learn more