processFormSubmission()
API v2.x
Overview
The simplest way to store form submission data is by submitting your form to process.php; the information is stored, the user is redirect to some sort of "thank you"page and everyone gets on with their life. But this approach doesn't handle more complicated scenarios such as:
- You want to add server-side validation to ensure the information is valid before adding to the database.
- You have a multi-page form and need to submit the data only on the very last step.
- You have a multi-page form and need to store the data page-by-page as the user progresses through the form.
- You want to submit the information, but don't want it to appear in the Form Tools UI until a later date.
Enter the API. The API comes with a number of methods designed to let you submit the information via PHP code, rather than through the more restrictive process.php POST script. The most important of these functions is the processFormSubmission() class method.
Fundamentally, Form Tools doesn't care HOW the information gets into the database. What's important is that it gets there.
Finalizing submissions
Every form submissions in the Form Tools database has a finalized flag: "yes" or "no". By default, submissions
sent via process.php are set to
finalized. Submissions sent via processFormSubmission()
are NOT finalized. Only finalized submissions
appear in Form Tools.
Related Links
To understand the processFormSubmission() method better, we suggest reading one of these tutorials:
Parameter keys
For completion, here's all the values that may be passed via the single parameter (a hash). But we strongly suggest giving one of the above tutorials a read first, otherwise this won't make all that much sense.
1. Required keys
2. Optional keys
initFormPage()
, for where the form
values will be stored temporarily in sessions, you need to pass that same value to
this function - otherwise it won't be able to retrieve the form and submission ID.