Forums

How to submit Form data at each page submit

earthwatch 08 Mar, 2018
Hi,

We have a form that is 4 pages and we would like to submit the data each time they press the next button to avoid the form timing out as some of the questions are pretty long.

How would I submit the data at each Next Page submit?

Thanks
Paul.
GreyHead 08 Mar, 2018
Hi Paul,

Add a Save Data action on Page 2, then add the new record ID to the form data on the following pages, and add Save Data actions on the following pages too.

Bob
earthwatch 08 Mar, 2018
Hi Bob, hope you are well.

I get the first part add the Save Data, but how do I add 'the new record ID' to the following pages? I looked at the available drag on items, but this is not one of them.

Thanks
Paul.
earthwatch 19 Mar, 2018
Hi Bob, hope you are well.I get the first part add the Save Data, but how do I add 'the new record ID' to the following pages? I looked at the available drag on items, but this is
not one of them.
ThanksPaul.
GreyHead 08 Apr, 2018
Hi Paul,

With a lot of trial and error I think I have this working. (There may be a better solution!)

I tested with the Demo multi_page form and added a Save Data action to the Page 2 event. That generates an 'aid' value for the new record. To get this into the form data I added a PHP action after the DB Save with this code:
$id = $this->get('save_data10.aid', '');
$this->data('aid', $id, true);
Note - data10 is the name of my Save Data action.

This adds the value of aid to the form data, but to get it carried forward to the next page the PHP Action needs to be followed by a Multi-Page action. I added a second one but I think that dragging the first one down will work as long as it remains before any actions that use data from a previous page.

Once the aid value is in the form data following pages should use that to update the existing record without requiring anything extra to be done.

Bob
earthwatch 09 Apr, 2018
Hi Bob, thanks for your reply. I tried adding the PHP code as you explained on page 2 after the save data, but get this error:Parse error: syntax error, unexpected '' (T_STRING) in /******/extensions/chronofc/functions/php/php_output.php(6)
: eval()'d code
on line 2

I added the code you explained:
$id = $this->get('save_data25.aid', '');
$this->data('aid', $id, true);

Screenshot:


Any ideas?

Thanks
Paul.
GreyHead 09 Apr, 2018
Hi Paul,

Did you copy and paste the code from my post here - if so, please try re-typing from scratch. Forum copies seem to contain some odd invisible characters - I got JavaScript errors when trying that.

If that isn't it you could try re-placing the single quotes with double quotes - though single quotes are working fine on my test form.

Bob
earthwatch 09 Apr, 2018
Hi Bob, I retyped the text and now no error, but still saves to separate lines in the db. See below my screenshot of the order of code / save data, is this correct? Also I have tried the Save Data > Write Action to be Auto Detect and Insert Duplicate Key Insert but neither work.
GreyHead 09 Apr, 2018
Hi Paul,

Is the ID column in your table named 'aid'? If not you need to replace aid in the code with the correct column name.

What do you see if you add a Debugger action - down at the bottom you should see the value of aid and the DB query that is being created.

Bob
earthwatch 10 Apr, 2018
Hi Bob, yes I am using 'aid' as the column, I have added the debugger as the end action on page 2, please see below for results, it does seem to bring through the aid:

Array
(
    [chronoform] => teach-earth
    [event] => page2
    [title] => Mrs
    [first_name] => Paul
    [last_name] => Spyker
    [email_address] => pspyker@earthwatch.org
    [confirm_email] => pspyker@earthwatch.org
    [school_name] => ds
    [street_1] => sd
    [street_2] => sd
    [town_city] => dsdsds
    [county] => ds
    [post_code] => ds
    [find_out] => News
    [newsletter] => 
    [payee] => 
    [disadvantagedarea] => 
    [Next_Step] => 
    [34228dc26f0d52f519647e7f1d44f173] => 15e4979f63a2a9f8c416a632bff219cb
    [142cb0b06bce91f2690f0ae42cdceaf3] => c360a5865b91060f75caa08e2144cb12
    [Itemid] => 399
    [option] => com_content
    [view] => article
    [id] => 1
    [teach-earth] => 
    [aid] => 43
)
Array
(
    [save_data25] => Array
        (
            [data] => Array
                (
                    [created] => 2018-04-10 16:34:11
                    [user_id] => 0
                    [title] => Mrs
                    [first_name] => Paul
                    [last_name] => Spyker
                    [email_address] => pspyker@earthwatch.org
                    [confirm_email] => pspyker@earthwatch.org
                    [school_name] => ds
                    [street_1] => sd
                    [street_2] => sd
                    [town_city] => dsdsds
                    [county] => ds
                    [post_code] => ds
                    [find_out] => News
                    [newsletter] => 
                    [payee] => 
                    [disadvantagedarea] => 
                    [attend_training] => 
                    [experiment] => 
                    [sdgs] => 
                    [outside_activities] => 
                    [camp_tents] => 
                    [group_discussions] => 
                    [action_plan] => 
                    [evaluation_process] => 
                )

            [_success] => Data saved successfully
            [log] => Array
                (
                    [0] => INSERT INTO `wzhmj_chronoforms_data_teach-earth` (`created`, `user_id`, `title`, `first_name`, `last_name`, `email_address`, `confirm_email`, `school_name`, `street_1`, `street_2`, `town_city`, `county`, `post_code`, `find_out`, `newsletter`, `payee`, `disadvantagedarea`, `attend_training`, `experiment`, `sdgs`, `outside_activities`, `camp_tents`, `group_discussions`, `action_plan`, `evaluation_process`)  values  ('2018-04-10 16:34:11', '0', 'Mrs', 'Paul', 'Spyker', 'pspyker@earthwatch.org', 'pspyker@earthwatch.org', 'ds', 'sd', 'sd', 'dsdsds', 'ds', 'ds', 'News', '', '', '', '', '', '', '', '', '', '', '');
                )

            [var] => Array
                (
                    [created] => 2018-04-10 16:34:11
                    [user_id] => 0
                    [title] => Mrs
                    [first_name] => Paul
                    [last_name] => Spyker
                    [email_address] => pspyker@earthwatch.org
                    [confirm_email] => pspyker@earthwatch.org
                    [school_name] => ds
                    [street_1] => sd
                    [street_2] => sd
                    [town_city] => dsdsds
                    [county] => ds
                    [post_code] => ds
                    [find_out] => News
                    [newsletter] => 
                    [payee] => 
                    [disadvantagedarea] => 
                    [attend_training] => 
                    [experiment] => 
                    [sdgs] => 
                    [outside_activities] => 
                    [camp_tents] => 
                    [group_discussions] => 
                    [action_plan] => 
                    [evaluation_process] => 
                    [aid] => 43
                )

        )

    [php28] => Array
        (
            [returned] => 
            [var] => 
        )

)
GreyHead 11 Apr, 2018
Hi Paul,

There is something odd here - you are showing aid = 43 in the form data - yet the Save Data action is showing the same aid = 43 after an INSERT request. The logic does not make sense. Please can you check the sequence of actions to check the logic.

Bob
Max_admin 13 Apr, 2018
Hi,

What data provider is used in the "Save data" action ?

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
earthwatch 16 Apr, 2018
Hi Max, the data provider field is blank. Should it contain something and if so what?
Bob, can I send you access to the form, it may be easier than me trying to explain what is what? I will email you the information.

Thanks
Paul.
GreyHead 17 Apr, 2018
Hi Paul,

I'm not sure but I think that the problem - or a part of it - is that you need to have the Multi-Page action(or a second Multi-Page action) in the Page 2 event (the first time you save data) *after* the Save Data action otherwise the value of aid is not saved and carried forward with the rest of the data. The php29 code you have at the start of the Page 3 action is almost certainly doing nothing useful.

Bob
earthwatch 17 Apr, 2018
Hi Bob, I don't fully understand your note above, but from what I can tell you are asking me to add another Multi-page action after the save data event. I did this, see below but still it saves each page as a separate line in the database. Am I missing something from you message above?

GreyHead 17 Apr, 2018
Hi Paul,

Please move it down below the PHP action where you are adding the aid value to the form data.

Bob
earthwatch 17 Apr, 2018
Hi Bob, tried that but still no luck.
GreyHead 17 Apr, 2018
Hi Paul,

OK :-(

Please add a Debugger in the Page 3 Event as the last action so we can see what data is there.

Bob
earthwatch 17 Apr, 2018
Hi Bob, please see below:
Array
(
    [chronoform] => teach-earth
    [event] => page3
    [attend_training] => 1
    [experiment] => 1
    [sdgs] => 1
    [outside_activities] => 1
    [camp_tents] => 1
    [group_discussions] => 1
    [action_plan] => 1
    [evaluation_process] => 1
    [button5] => 
    [34228dc26f0d52f519647e7f1d44f173] => dd793d2c51ffde0863d1b1ff48046373
    [142cb0b06bce91f2690f0ae42cdceaf3] => c1875a7e9de37850d1b5fb8caf0be417
    [Itemid] => 399
    [option] => com_content
    [view] => article
    [id] => 1
    [teach-earth] => 
    [aid] => 
)
Array
(
    [php29] => Array
        (
            [returned] => 
            [var] => 
        )

    [save_data26] => Array
        (
            [data] => Array
                (
                    [created] => 2018-04-17 15:48:15
                    [user_id] => 0
                    [title] => 
                    [first_name] => 
                    [last_name] => 
                    [email_address] => 
                    [confirm_email] => 
                    [school_name] => 
                    [street_1] => 
                    [street_2] => 
                    [town_city] => 
                    [county] => 
                    [post_code] => 
                    [find_out] => 
                    [newsletter] => 
                    [payee] => 
                    [disadvantagedarea] => 
                    [attend_training] => 1
                    [experiment] => 1
                    [sdgs] => 1
                    [outside_activities] => 1
                    [camp_tents] => 1
                    [group_discussions] => 1
                    [action_plan] => 1
                    [evaluation_process] => 1
                    [what_is_your_profession_please_check_all_that_apply] => 
                    [work_type] => 
                    [education_level] => 
                    [environmental_education_activities] => 
                    [why_join] => 
                )

            [_success] => Data saved successfully
            [log] => Array
                (
                    [0] => INSERT INTO `wzhmj_chronoforms_data_teach-earth` (`created`, `user_id`, `title`, `first_name`, `last_name`, `email_address`, `confirm_email`, `school_name`, `street_1`, `street_2`, `town_city`, `county`, `post_code`, `find_out`, `newsletter`, `payee`, `disadvantagedarea`, `attend_training`, `experiment`, `sdgs`, `outside_activities`, `camp_tents`, `group_discussions`, `action_plan`, `evaluation_process`, `what_is_your_profession_please_check_all_that_apply`, `work_type`, `education_level`, `environmental_education_activities`, `why_join`)  values  ('2018-04-17 15:48:15', '0', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '1', '1', '1', '1', '1', '1', '1', '1', '', '', '', '', '');
                )

            [var] => Array
                (
                    [created] => 2018-04-17 15:48:15
                    [user_id] => 0
                    [title] => 
                    [first_name] => 
                    [last_name] => 
                    [email_address] => 
                    [confirm_email] => 
                    [school_name] => 
                    [street_1] => 
                    [street_2] => 
                    [town_city] => 
                    [county] => 
                    [post_code] => 
                    [find_out] => 
                    [newsletter] => 
                    [payee] => 
                    [disadvantagedarea] => 
                    [attend_training] => 1
                    [experiment] => 1
                    [sdgs] => 1
                    [outside_activities] => 1
                    [camp_tents] => 1
                    [group_discussions] => 1
                    [action_plan] => 1
                    [evaluation_process] => 1
                    [what_is_your_profession_please_check_all_that_apply] => 
                    [work_type] => 
                    [education_level] => 
                    [environmental_education_activities] => 
                    [why_join] => 
                    [aid] => 60
                )

        )

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

VPS & Email Hosting 20% discount
hostinger