FormItRetriever
Last updated Oct 7th, 2020 | Page history | Improve this page | Report an issue
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
Budget
$301 per month—let's make that $500!
Learn moreWhat 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¶
- FormIt.Hooks
- FormIt.Validators
- FormIt.FormItRetriever
- FormIt.Tutorials and Examples
- FormIt.FormItCountryOptions
- 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
Budget
$301 per month—let's make that $500!
Learn more