FormIt.FormItRetriever
Last edited by Joeke Kloosterman on Sep 26, 2016.
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.
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=`my@email.com` &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> <pre>[[!+fi.message]]
See Also
- FormIt.Hooks
- FormIt.Validators
- FormIt.FormItRetriever
- FormIt.Tutorials and Examples
- FormIt.Roadmap
- FormIt.FormItCountryOptions
- FormIt.FormItStateOptions
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab) or become an editor of the MODX Documentation.
Comment Policy
Comments intended to help other users with this document are welcome! If you have a suggestion for this Extra document, please attempt to contact the author directly, possibly on GitHub or in the MODX Community Forums.