What is FormIt?
FormIt is a dynamic form processing Snippet for MODx Revolution. It handles a form after submission, performing validation and followup actions like sending an email. It does not generate the form, but it can repopulate it if it fails validation.
FormIt was written by Shaun McCormick as a form processing Extra, and first released on October 19th, 2009.
Development and Bug Reporting
FormIt is stored and developed in GitHub, and can be found here: https://github.com/Sterc/FormIt
Bugs can be filed here: https://github.com/Sterc/FormIt/issues
API Documentation can also be found here: http://api.modx.com/formit/
How to Use
Simply place the FormIt snippet call into the Resource that contains the form you want to use. Unlike similar predecessors (most notably eForm in MODx Evolution), you do not put the form into a Chunk and reference the Chunk in the FormIt snippet call: you literally put the snippet call along side the form you want it to process. Specify the "hooks" (or post-validation processing scripts) in the snippet call. Then add validation via the &validate and &customValidators parameters in the snippet tag.
If you have multiple forms on a page, set the &submitVar property on your Snippet call to a name of a form element within the form (ie, &submitVar=`form1-submit`). This tells FormIt to only process form requests with that POST variable. Multiple forms should be used with INPUT type="submit" name="form1-submit", button elements have been reported not working.
These are the available general properties for the FormIt call (not including hook-specific properties):
|hooks||What scripts to fire, if any, after the form passes validation. This can be a comma-separated list of hooks, and if the first fails, the proceeding ones will not fire. A hook can also be a Snippet name that will execute that Snippet.|
|preHooks||What scripts to fire, if any, once the form loads. This can be a comma-separated list of hooks, and if the first fails, the proceeding ones will not fire. A hook can also be a Snippet name that will execute that Snippet.|
|submitVar||If set, will not begin form processing if this POST variable is not passed. Notice: Needed if you use &store property (+ set submit var in input="submit"!).|
|validate||A comma-separated list of fields to validate, with each field name as name:validator (eg: username:required,email:required). Validators can also be chained, like email:email:required. This property can be specified on multiple lines.|
|validationErrorMessage||A general error message to set to a placeholder [[!+fi.validation_error_message]] if validation fails. Can contain [[+errors]] if you want to display a list of all errors at the top.||
A form validation error occurred. Please check the values you have entered.
|validationErrorBulkTpl||HTML tpl that is used for each individual error in the generic validation error message value.||
|errTpl||The wrapper html for error messages. Note: not a chunk, just straight HTML.||[[+error]]|
|customValidators||A comma-separated list of custom validator names (snippets) you plan to use in this form. They must be explicitly stated here, or they will not be run.|
|clearFieldsOnSuccess||If true, will clear the fields on a successful form submission that does not redirect.||1|
|store||If true, will store the data in the cache for retrieval using the FormItRetriever snippet.||0|
|storeTime||If 'store' is set to true, this specifies the number of seconds to store the data from the form submission. Defaults to five minutes.||300|
|placeholderPrefix||The prefix to use for all placeholders set by FormIt for fields.||fi.|
|successMessage||If not using the redirect hook, display this success message after a successful submission.|
|successMessagePlaceholder||The name of the placeholder to set the success message to.||fi.successMessage|
|redirectTo||page ID of a "Thank You" page, where the visitor can be sent after successfully submitting the form, but this parameter is read ONLY if you include "redirect" in the list of &hooks.|
Validation in FormIt is done via the &validate property, and can be used to automatically handle validation on any of the fields in your form.
For more information on validation in FormIt, see the Validators page.
Hooks are basically scripts that run during FormIt processing. Hooks can be chained; the first hook will execute, and if succeeds, will proceed onto the next hook.
For more information on hooks, see the Hooks page.
- FormIt.Tutorials and Examples