Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
Ben,
I reviewed this post at http://forums.formtools.org/showthread.php?tid=225 and should work fine for me. However, if a user wants to save the form say, after the first page, and I know that Formtools saves each page as it moves from one to the other, what would you suggest in terms of user interface to allow the user to save the current data and exit the form, but be able to come back later and complete it?
When the user clicks on the NEXT button to go to the next page, the data is saved so could I add a SAVE button that simply saves the data from the currently filled out form page and then exits to a thankyou page that also gives them instructions about how to log back in an complete their submission. Is there an API call that allows that sort of thing? Also, can I call different thank you pages at different stages?
This should also work on forms that are all on a single page but simply have sections hidden or shown using javascript ... yes?
I know this might be beyond the current API but maybe not. As always Ben, your input is much appreciated.
Dave
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hey Dave,
This is something that I've done myself dozens of times for our own clients - and something I ultimately hope to solve once and for all with the Form Builder module (but not in the first release, sorry!).
So yes, you can totally do it. Since the API stores the info for all form submissions - incomplete or not - the issue is really a matter of how the user first gets to the form. What I always do is add a "login page", which contains a unique identifier of some form - usually the user's email - and a default password. Then, when they submit that form, it does a custom query against the database. If it finds the record, it manually sets that data in sessions - just as it would do automatically with the API for new submissions. Then, when they redirect to page 1 of the form, it contains those values.
For the other case - new registrants - the query would fail to find that user's email, so just run the API's create blank submission function and redirect.
It's kind of top level advice, but that's the general idea.
A slightly easier solution would be to use the Submission Accounts module. In your public form, pass the "finalize" => true key-value pair to the ft_api_process_form() function on the first form page, and add the "may_update_finalized_submissions" => true to all subsequent pages. With that in place, the submission will automatically appear in the FT interface after page 1 - even if it's incomplete. You could then use the Submission Accounts module to let them log in there and complete filling in their submission.
- Ben
Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
Thanks Ben, I'll look this over tomorrow after I have had some sleep. I can barely see the screen now :-)
Cheers,
Dave
Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
Hey Ben,
I have been trying to get the submission module to work with not much success. I have this in the top of my page ( this is a single page form because I am using javascript to show/hide section of the form rather than use multiple pages - let me know if this will not work):
Code: <?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/support/formtools/global/api/api.php");
ft_api_start_sessions();
$fields = isset($_SESSION["form_tools_form_data"]) ?
ft_strip_tags($_SESSION["form_tools_form_data"]) : array();
$fields = ft_api_init_form_page(1);
$params = array(
"submit_button" => "submit",
"next_page" => "/profiler/thanks.php",
"form_data" => $_POST,
"file_data" => $_FILES,
"finalize" => true,
"may_update_finalized_submissions" => true
);
ft_api_process_form($params);
?>
When I come back and try to log into the formtools admin using the email (I am using the email address as the username ) and password originally supplied from the form, the @ sign and the period gets stripped from the username and the login fails.
The other thing I am not sure of, assuming I will get this working is if the user who logs in can see all submissions, or simply all submissions that match the user/pass combination. I assume the later?
Dave
Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
Feb 24th, 2012, 11:25 AM
(This post was last modified: Feb 24th, 2012, 11:40 AM by filch.)
Hi Ben,
I am finally getting back to fixing a few bothersome problems with this form. You may not remember this but this form allows a user to fill in all or just some of the fields (other than required fields) and come back later to complete it. The one standout problem I am having is that is the user Saves before he completes the form, I would think that the "next_page" => "thanks.php", should kick in, shouldn't it? However, it is not. Any idea why not? Here is the code I have at this point:
Code: <?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/support/formtools/global/api/api.php");
ft_api_start_sessions();
$fields = isset($_SESSION["form_tools_form_data"]) ?
ft_strip_tags($_SESSION["form_tools_form_data"]) : array();
$fields = ft_api_init_form_page(1);
$params = array(
"submit_button" => "submit",
"next_page" => "thanks.php",
"form_data" => $_POST,
"file_data" => $_FILES,
"finalize" => true,
"may_update_finalized_submissions" => true
);
ft_api_process_form($params);
?>
If the user Saves (submits) the form before it is complete, the thanks.php page should come up, but it does not. Could it be that the problem is that this is not a true multi-page form but rather, a single page in which we show or hide elements with jQuery?
Cheers,
Dave
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hey Dave,
Any luck with this? If not, are you using an image submit button? That seems to be coming up a lot recently - if so, check out this post:
http://forums.formtools.org/showthread.p...age+submit
- Ben
Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
Mar 8th, 2012, 12:13 PM
(This post was last modified: Mar 8th, 2012, 12:37 PM by filch.)
(Mar 2nd, 2012, 12:15 AM)Ben Wrote: Hey Dave,
Any luck with this? If not, are you using an image submit button? That seems to be coming up a lot recently - if so, check out this post:
http://forums.formtools.org/showthread.p...age+submit
- Ben
Hey Ben. Nope! Not using an image for a button. Standard submit styles with CSS. I can send you the URL if you want to have a peek?
Dave
I tried adding a hidden field but that does not work either. I added
echo "<pre";
print_r($_POST);
echo "</pre>";
to the top of the page and here are the values for submit and the hidden field:
[submit] => SAVE
[is_submitted] => 1
Any clues here?
Dave
Tried everything I can think of but no luck :-((
|