FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two forms on the same page
#11
(Mar 20th, 2010, 9:36 AM)Jaace Wrote: Hi Dave,

Not sure if you're using the Paypal enabled form functionality...but that's why I have the if-else statement on mine and pp["mode"]. In Ben's documentation of Paypal his demo files are set up like this so that you don't have to worry about changing that field except in the library.php file. It tests to see if it's in initialize mode (set up) and if so, executes that statement...if not (live mode) it goes to the else statement.

Short answer... I believe yours should read:
Code:
$fields_10 = ft_api_init_form_page(10, "live", "form_tools_form_10");

...or if you have $pp["mode"] set to "live" ($pp["mode"]= "live"Wink
Code:
$fields_10 = ft_api_init_form_page(10, $pp["mode"], "form_tools_form_10");
Thanks for your reply. I tried setting it the way you have it in your first example and it still throws a 200 error. It is the way I would have thought it would work though. Unless it has something to do with not clearing the sessions first before I tested it. I added the following to my thanks page:
Code:
require_once("/web/home/support/docs/assets/scripts/formtools/global/api/api.php");
$fields = ft_api_init_form_page();
ft_api_clear_form_sessions("form_tools_form_9");
ft_api_clear_form_sessions("form_tools_form_10");

but that did not seem to help.

Dave
Reply
#12
(Mar 20th, 2010, 10:08 AM)filch Wrote:
(Mar 20th, 2010, 9:36 AM)Jaace Wrote: Hi Dave,

Not sure if you're using the Paypal enabled form functionality...but that's why I have the if-else statement on mine and pp["mode"]. In Ben's documentation of Paypal his demo files are set up like this so that you don't have to worry about changing that field except in the library.php file. It tests to see if it's in initialize mode (set up) and if so, executes that statement...if not (live mode) it goes to the else statement.



Short answer... I believe yours should read:
Code:
$fields_10 = ft_api_init_form_page(10, "live", "form_tools_form_10");

...or if you have $pp["mode"] set to "live" ($pp["mode"]= "live"Wink
Code:
$fields_10 = ft_api_init_form_page(10, $pp["mode"], "form_tools_form_10");
Thanks for your reply. I tried setting it the way you have it in your first example and it still throws a 200 error. It is the way I would have thought it would work though. Unless it has something to do with not clearing the sessions first before I tested it. I added the following to my thanks page:
Code:
require_once("/web/home/support/docs/assets/scripts/formtools/global/api/api.php");
$fields = ft_api_init_form_page();
ft_api_clear_form_sessions("form_tools_form_9");
ft_api_clear_form_sessions("form_tools_form_10");

but that did not seem to help.

Dave

In a multi-page form, I would think that you have to use either an if/then or a switch statement structure to make this work as otherwise, how would the API know which form was submitted. It uses the submit button name to differentiate I believe. So you would have to check which submit button was pressed would you not?

Dave
Reply
#13
Jaace,

Did you not get an error when you used stripslashes_deep($_POST)??

I do and am wondering if it should not be:

"form_data" => array_map( 'stripslashes_deep', $_POST ),


Dave


(Mar 1st, 2010, 9:25 PM)Jaace Wrote: I've got two forms on the same page that go to different submissions pages (this is for a Paypal IPN payment type). These are both single form submissions..and everything seems to be fine except that one of the forms won't save to the database. I'm not exactly sure why...but I have a feeling it is due to the fact that I'm doing this on the page:
Code:
$fields = ft_api_init_form_page(8, $pp["mode"]);
$fields = ft_api_init_form_page(9, $pp["mode"]);

...now I know what you're thinking: Don't do that then! The problem is I don't know what else to do to declare these fields variables. The user could essential fill out either of the forms...not sure which one..so I need to do the $fields for both of them. Is there a way to do this? Or is the way I'm doing this fine and it's some completely different problem?

Thanks for your help :-)
Since the forms that appear on this page are both single page forms, I've chosen to do the following:
Code:
if (isset($_POST['form_9_submit'])) {
    $fields = ft_api_init_form_page(9, $pp["mode"]);
    $pp["form_id"] = 9;

    if ($pp["mode"] == "initialize") {
        $params = array(
            "submit_button" => "send",
            "next_page" => "/form-9-success",
            "form_data" => stripslashes_deep($_POST),
            "finalize" => true
        );
    } else {
        $params = array(
            "submit_button" => "send",
            "next_page" => "/form-9-submit",
            "form_data" => stripslashes_deep($_POST),
        );
    }
    ft_api_process_form($params);
} else if (isset($_POST['form_8_submit'])) {
    $fields = ft_api_init_form_page(8, $pp["mode"]);
    $pp["form_id"] = 8;

    if ($pp["mode"] == "initialize") {
        $params = array(
            "submit_button" => "approve",
            "next_page" => "/form-8-success",
            "form_data" => stripslashes_deep($_POST),
            "finalize" => true
        );
    } else {
        $params = array(
            "submit_button" => "approve",
            "next_page" => "/form-8-submit",
            "form_data" => stripslashes_deep($_POST),
        );
    }
    ft_api_process_form($params);
}

What I've done is to place the $fields variable inside of the if-else conditional based upon which submit button is clicked. I don't really need to worry about the fields getting filled in if the user navigates back to this page before submitting...since it will rarely happen, and there isn't a lot of stuff to fill out.

What I want to know is if this will hurt anything down the road...besides hindering the ability to fill in the fields from sessions. I don't see any other problems with this myself...but I'd like some other opinions/thoughts.

Thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)