Forums

Data on page 1 of 3 page form not recorded

dnigra 27 Mar, 2017
using Joomla 2.5.7

I have a 3 page workshop application form. The first page collects contact info: first and last name, email, phone, address, etc. The 2nd page collects information about the experience and education of the applicant; the 3rd, demographic info required by our funding body.

Required fields are set as such, of course, and on moving to the next page, there is a server side validation that checks that there is data in the required fields on the previous page and returns to the previous page if something is amiss.

I've tested and had others test. I can't move past the 1st page if I haven't completed all the required fields.

I am now getting some submissions with no data at all for the data from page 1. However, page 2 and 3 data is complete, and sensible information. There are 3 short essays on those pages and they are reasonable, so I do not think this is a malicious attempt.

I am also getting some submissions that are fine, all data is complete.

Here is what is in the error logs:
error_log-20170326:[Fri Mar 24 14:37:39 2017] [error] [client 128.237.182.54] PHP Notice: Undefined index: first_name in /var/www/html/administrator/components/com_chronoforms5/chronoforms/actions/custom_code/custom_code.php(20) : eval()'d code on line 2, referer: http://www.mmbios.org/hands-on-workshop-on-computational-biophysics-2017/application?view=form&chronoform=ComputationalBiophysics2017&event=page3
error_log-20170326:[Fri Mar 24 14:37:39 2017] [error] [client 128.237.182.54] PHP Notice: Undefined index: mi in /var/www/html/administrator/components/com_chronoforms5/chronoforms/actions/custom_code/custom_code.php(20) : eval()'d code on line 2, referer: http://www.mmbios.org/hands-on-workshop-on-computational-biophysics-2017/application?view=form&chronoform=ComputationalBiophysics2017&event=page3
error_log-20170326:[Fri Mar 24 14:37:39 2017] [error] [client 128.237.182.54] PHP Notice: Undefined index: last_name in /var/www/html/administrator/components/com_chronoforms5/chronoforms/actions/custom_code/custom_code.php(20) : eval()'d code on line 2, referer: http://www.mmbios.org/hands-on-workshop-on-computational-biophysics-2017/application?view=form&chronoform=ComputationalBiophysics2017&event=page3

Two things: 'mi' is not a required field; note that the error comes on page3, not page 2, where the name field checks are.

I've attached screenshots of the "on page 2" action and then detail of the server validation action that happens "on page 2".

Any idea what might be happening? Also note that some submissions are fine.
GreyHead 28 Mar, 2017
Hi dnigra ,

The PHP Notices are probably harmless - they appear to be coming from some Custom Code in the form.

I suggest that you put the ServerSide validation before the Multi_page action so that you don't store unvalidated data.

The problem may be that you the for takes some time to complete and the User session expires losing some data. You can make the User session longer (default is 15m), or better save the data to a Database table when each page is submitted.

Bob
dnigra 28 Mar, 2017
Hi Bob,

Thanks for your prompt reply. I've implemented your suggestions about doing validation before the Multi_page action and saving the data when each page is submitted. Unfortunately, two records are created for each form submission. The first has page 1 data only, and the second has data from all 3 pages. so luckily I am not timing out here.

So that the data will all be saved to the same record I tried to use the cf_id field as given in this FAQ: http://www.chronoengine.com/faqs/63-cfv4/cfv4-working-with-form-data/2596-how-can-i-give-a-unique-id-to-each-form-submission.html

The cf_id field is empty in all records. Using the debugger also shows that it is empty. The id field seems to get set after page 1 is submitted. See the attached debug output where it is listed after the button field, the 'name' field (which is set in a custom action on page2) and 'ip_address' and before the 'ProDy' field. 'ProDy' is the first field on page 2.

This example shows id=6. The page 1 data is saved in record 5. Record 6 has all the data from all pages of the form, including 1.

onPage 2 actions are also attached.

Obviously I need to tweak something. What is wrong?

Thanks again.
GreyHead 28 Mar, 2017
Hi dnigra,

To update the same record you need to capture the record ID and use that in the later DB Save record conditions boxes. As you see ChronoForms adds the record ID to the form data after the first DB Save.

In CFv4 the default primary key columnname was cf_id - in CFv5 this changed to just id but can sometimes cause conflicts with article ids or other things called 'id'. I prefer to use cf_id for safety.

You need to pass the record id to the later submit pages - you can do this using a hidden form element with the same name - id or cf_id

Bob
dnigra 28 Mar, 2017
I'm a little confused.

There are 3 form pages. There is a DB save action when each page is submitted.

There are 2 records saved when the form is completely filled out and submitted. The first one only has page 1 data. The second one has data from all 3 pages.

If I need to pass the record id, and I'm not, why aren't there 3 records created, one with data from page 1, the 2nd with pages 1 & 2 data, and the 3rd with data from all 3 pages?
GreyHead 28 Mar, 2017
Hi dnigra,

I've no idea - ChronoForms is pretty logical, Add Debugger actions on each page so that you can see what data is there and exactly what MySQL query is being created.

Bob
dnigra 29 Mar, 2017
Hah! Thanks, glad to know I am not missing something glaringly obvious. If I figure it out, I'll let you know.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger