Forums

Confirmation page shows double in multi-page form

Von Steiner 19 Apr, 2011
Hi,

I have a multi-page form with 2 children and a mother form. The first form saves its data to an array which is then added to the $_POST array for the second form and the whole lot is saved to 2 tables in the same DB by the second child form. That works fine when I just link them together with no confirmation page.

The mother form is connected to the two tables and when the confirmation plug-in is turned off, the data just slips right into the DB where it should be. The child forms are NOT connected to their respective DB tables. I want to save the data at the end of the process so that I don't get any orphan records if the process is abandoned halfway through.

I want the user to be able to see the data from the form they just completed and be able to go back and correct it if necessary.

However, when I add a confirmation page on the first child form, I get weird results: the form displays the confirmation template, with the data and the Next, Back buttons, BUT displays the same form again beneath that. If I click the Next or Back buttons, it reloads the form again, empty and with none of the confirmation template.

Here's a tidbit that's going to ring someone's bells: the Chronoforms credits "Powered By ChronoForms - ChronoEngine.com" appears twice at the bottom of the confirmation page.

Debug messages from the confirmation plugin are, at the top of the page:

Posted: Array ( [empuniqueid] => phyLTvc [empgivenname] => Henrietta [empfamname] => Magic-Bones Hawhaw [edob] => 08/04/1991 [empregionbirth] => Jupiter and Mars [empcountrybirth] => Guam [empidcard] => 1010101010 [emppassportno] => 2020202020 [emppassportcntry] => Equatorial Guinea [button_7] => Next [2fedb9d9cef211898f00b8e7b7cf0425] => 1 [1cf1] => b0ec34b87e6bb7ecc2ea074a94291378 [chronoformname] => mothertest )
Files: Array ( )
Current step: 1


and just above the second instance of the form:

$params: JParameter Object ( [_raw] => stepscount=2 formsnames=employeeinfo,ayiempreport finalbuttonname=Finish stepsnavigation=1 debugging=1 onsubmit=before_email [_xml] => [_elements] => Array ( ) [_elementPath] => Array ( [0] => C:\xampp\Joomla1-5\libraries\joomla\html\parameter\element ) [_defaultNameSpace] => _default [_registry] => Array ( [_default] => Array ( [data] => stdClass Object ( [stepscount] => 2 [formsnames] => employeeinfo,ayiempreport [finalbuttonname] => Finish [stepsnavigation] => 1 [debugging] => 1 [onsubmit] => before_email ) ) ) [_errors] => Array ( ) )
formname: mothertest
Pages: Array ( [0] => employeeinfo [1] => ayiempreport )
Current step: 1
Session data: Array ( ) 


Obviously I am trying to torture this into doing something in a way it doesn't like. Any suggestions on where to look and what for are most welcome.

Thanks.

Justin
GreyHead 19 Apr, 2011
Hi Justin,

The Confirmation Page plug-in tries to take over the form submission process and doesn't do a very good job of it. In this case both the Multi-Page and Confirmation Page plug-ins are trying to manage the process.

I suggest that you turn off the Confirmation page plug-in and simply create an extra child form in the flow to display the data you want confirmed.

Bob
Von Steiner 20 Apr, 2011
Thanks, Bob. I'll try that.

Nice to know that it wasn't me for once... ;-)

Justin
exorzy 23 Apr, 2011
Hi guys

I am trying the same thing with a 2 pages form and a confirmation page.

Now a question to GreyHead's Suggestion: How am I able to display data from my Step1-form in a third child form?

I guess I can't access the data from step1 by {}-Tags...right?

Thanks in advance.
Robert Krieg
Von Steiner 23 Apr, 2011
Hi Robert,

Here's how.

Make a blank confirmation page Chronoforms and edit the Form HTML manually.

Use PHP in the HTML Form code for your confirmation page to display each of the fields the user entered on the previous page. The $_POST array contains everything from the form that was just submitted.

Here's the format (I assume you can figure out the other HTML to make it pretty)

<p>Your form field name:       <?php echo $_POST['your_form_field_name']; ?><br /></p>


Repeat this for all the fields you want to display for confirmation, replacing your_form_field_name with the actual field name.

To navigate back and forth between pages, go to the mother page configuration in Chronoforms Form Configuration. Click the checkbox next to the mother form and click 'Multi Page'; select 'Yes' for 'Enable steps navigation'.

Put links in your Form HTML (regular text links or images, whatever) in the format:

<a href="index.php?option=com_chronocontact&chronoformname=your_mother_form_name_here&cfformstep=1">BACK</a> 
<a href="index.php?option=com_chronocontact&chronoformname=your_mother_form_name_here&cfformstep=3">NEXT</a>


Replace 'your_mother_form_name_here' with the name of your mother form.

The first page will be '1' the confirmation page will be '2' and the second form will be '3' etc.

--> Make sure you turn off the confirmation page plugin for all your pages (mother and children) if you were playing around with it earlier.

--> Also make sure you add the confirmation page to the mother forms chain list AND adjust the number in the chain manually (I forgot this and wasted 20 minutes).

If you want to pass the 1st forms data along the chain, you'll need save the $_POST array in another array so that it doesn't get replaced by the new forms data. Here's the code Bob suggested that works fine for me:

<?php
     if ( !$mainframe->isSite() ) { return; }
     $session =& JFactory::getSession();
     $posted = $session->get('chrono_formpages_data_yourformnamehere', array(),md5('chrono'));
?>


Put this in the "OnSubmit before email' box. It puts the values of the form fields into the regular old array $posted, which isn't reset for every form, like $_POST is.

Then, in the beginning of the new form, assign the $_POST elements for the new page the values of the $posted array from the previous page like this:

<?php $_POST['variable_name']=$posted['variable_name'] ?>


If your field names are unique, you should then be left with a large $_POST array which acts like a large single form when you submit the final form.

If you save the form data between each form and the forms are related, you may be left with orphan or incomplete records [EDIT: if the user bails out halfway through]. That's why it's better in that case to wait until the last step and save it all at once.

Justin
exorzy 23 Apr, 2011
Hi Justin

Thank you very much for your detailed explanation. I will try that!

Thanks!!

Robert
Nadeem 07 Aug, 2011
Hey Guys , I read your post, I followed it but I m not able to configure the mulit- page as well as session, here is wat i m doing. I am new to joomla and on top of that chronoforms is taking too much time of mine.. I m not storing this data in DB, but only to fill up the form n send the data to another python application in another server thru XMLRPC... i m not sure to go for other forms as they r not free or to build my own component.. please help....

1> Created a form_1(Testone) , onSubmit field= I added the $_POST data in an array like shown below:
<?php
$session = JFactory::getSession();
$cart = array();
$cart['name']=$_POST['text_0'];
$cart['email']=$_POST['text_3'];
$session->set('cart', $cart);
php echo $cart; ?>


2> created another form_2(confirmation) - added html text in Form HTML as shown below:
<p>Your form field name: <?php echo $_POST['text_0']; ?><br /></p>
<p>Your form field name: <?php echo $_POST['text_3']; ?><br /></p>
<a href="index.php?option=com_chronocontact&chronoformname=Testone&cfformstep=1">BACK</a>
<a href="index.php?option=com_chronocontact&chronoformname=Testone&cfformstep=3">NEXT</a>

3>created final form_3(signup)- added the html text to be submitted: final submission to XMLRPC plugin

Now issues i m facing is, I m not able to load $_POST data into session to carry out in same in nxt page(check the code showed in form_1 on submit)

Now issue-2 is using the mother form i choose multi-page from the plugin and configure it like this :
Number of Steps-2
Step form names- confirmation,signup
Finalize button name-submit
Enable Steps navigation- yes
Debugging - No

But I don see any session data(echoin $cart) or form confirmation page....Please guide ... i
GreyHead 23 Aug, 2011
Hi Nadeem,

Is this still a problem?

Bob
Nadeem 24 Aug, 2011
YES its solved, I think its not a problem anymore !! please see my other post about paypal express checkout , I need a solution... else all these days i worked around to make my chronoform work will go in vain..
This topic is locked and no more replies can be posted.