-
- 670 Posts
Hi
I want a simple form on my homepage which collects basic data - and after submitting takes the user to part 2 of the form which requires more detail.
If they don't complete part 2, at least we have basic info from part one stored and emailed.
What's the best method in modx for something like this?
Thanks
Andy
-
- 11 Posts
Are you submitting the data on another page then the page that contains the second form ? if so you could store the information in a session
-
- 670 Posts
Yes it fouls be a second page. But I want to collect the data in between submissions if that makes sense?
-
- 932 Posts
How are you hoping to attribute data to the user on the second form? Will some values be repeated on the second form such as name or email ?
You could perhaps create it as two seperate formit calls and after the first one is submitted redirect to the second form and use formit retriever to retrieve some details in a hidden field, such as email.
The problem though will be when you want to merge the data together. It may be a manual process of matching ip address or email submissions together.
If the users will be registered and logged in on the site then it could be a different scenario potentially.
-
- 24,544 Posts
One method would be to use a custom snippet to process the form submission on the first page. That snippet could save the form data in a $_SESSION variable as Jasper suggests, send an email, and/or perform other tasks, then forward the user to the second form's page with $modx->sendRedirect($url).
On that second page, a custom snippet at the top could grab the $_SESSION variable, use it to set placeholders, and clear the $_SESSION variable.
As LK said, merging the data from the two forms could be tricky.
-
- 24,544 Posts
That should work if the first form posts to the second one, though you're going to need some code on the second form to get the values and fill the fields.
Using the $_SESSION variable would be more secure and would accomplish the same thing. Setting them as placeholders would do the autocomplete part.