Forums

Saving Intermediate results

susans 18 Oct, 2012
I have a multi page form that I am trying to have it save the data when the user moves from the first page to the second page.

On the second page I have created a hidden field cf_id which is supposed to have the the value of the new row that was created.

In my On Page 2 Events I have the following:
Check Captcha - I have a captcha on the first page that I want to verify
Data To Session - to load the data from the previous page
DB Save - save the data to the database (which is working)
Debugger - to see the output of the intermediate step
Multi Page - just following the directions I read somewhere
Show html - to show the second page of the form

In the debugger output I see:
Data Array:

Array
(
    [option] => com_chronoforms
    [tmpl] => component
    [chronoform] => RegisterSaveIntermediate
    [event] => Page 2
    [cf_sid] => a7719ad82122264ea01b100a70816eab
    [Itemid] => 
    [lang] => en
    [first_name] => ac
    [last_name] => cc
    [Passport_number] => xxx
    [chrono_verification] => efXSB
    [to_page_2] => Next Page
    [42424209238c1efc0e61c9a2a35fe2a4] => 1
    [language] => en-GB
    [chronoform_data] => Array
        (
            [cf_uid] => 0d4b317915f3fdf3255ad7b95ddcd153
            [cf_created] => 2012-10-18 04:23:47
            [cf_created_by] => 0
            [cf_ipaddress] => 192.117.97.121
            [cf_user_id] => 0
            [option] => com_chronoforms
            [tmpl] => component
            [chronoform] => RegisterSaveIntermediate
            [event] => Page 2
            [cf_sid] => a7719ad82122264ea01b100a70816eab
            [Itemid] => 
            [lang] => en
            [first_name] => ac
            [last_name] => cc
            [Passport_number] => xxx
            [chrono_verification] => efXSB
            [to_page_2] => Next Page
            [42424209238c1efc0e61c9a2a35fe2a4] => 1
            [language] => en-GB
            [cf_id] => 4
        )

    [chronoform_data_cf_id] => 4
)

Validation Errors:

Array
(
)

Debug Data

    Core Captcha
        Passed the core captcha check!


However, when I look at the HTML generated for the second page the hidden form cf_id has no value (i.e. value="").

I tried Adding a Data to Session event or a Session to Data event after the DB Save event but neither made any difference.

What do I have to do to have the field filled in correctly? Without that subsequent saves will end up creating new records instead of updating the existing record.
GreyHead 18 Oct, 2012
Hi susans,

The Multi Page action uses the 'Data to Session' and 'Session to Data' actions to carry the form data forward so you don't need both. Please then move the Multi-Page action up before the DeBugger so that you can see exactly what you have.

The cf_id value you are looking for is 4 in this case and is in chronoform_data_cf_id

Bob
susans 18 Oct, 2012
I moved the Multi Page action above the Database Save and removed the Data To Session and Session to Data actions.

The behavior is the same. The hidden field (which should be populated with the cf_id automatically) still comes up with value=""
GreyHead 18 Oct, 2012
Hi susans,

Please add a Custom Code action after the Db Save action and put this code into it:
<?php
$form->data['cf_id'] = $form->data['chronoform_data_cf_id'];
?>

Bob
susans 18 Oct, 2012
Thank you, that solved the problem. In general, is it necessary to have that custom code? From what I read I thought that it was supposed to populate the cf_id automatically?
GreyHead 18 Oct, 2012
Hi susans,

I think I would expect that too but I haven't dug into the code to see exactly how it is set up.

Bob
This topic is locked and no more replies can be posted.