Your opinion to this page?
Deutsch Deutsch English English

 Private Functions <<    ^ CMS module: MPForm (Homepage of the module) ^    >> Field Types of MPForm 

MPForm Documentation: Loops in forms

Level of difficulty: C 

If you ever tried to do programming tasks, you probably know what a loop means in the flow of a program. If not, just imagine you have to put a question like "list the names, birth dates and some more data of your childs" into a form, with a separate field for each data element. The possible range of childs goes from 0 up a very large number. At least you should get the idea now:
You need to loop through the same page of the form until the answer to the question "Have you more children?" is No.

Now how can you do this with a Website Baker form?

And ready is your form loop.


Now you had some hundred visitors who entered lots of data into your large multi page form, and you need to make some statistics.

The best way to offer the data in the frontend is by using the csvexport module. Take care of its security hints!

Each line in the csv file will represent the answers from one user for all pages with the same Name suffix for results table set in the backend. When creating a multi page form, it makes sense to use the same suffix for each page of the form, and for no other form! Do not change the suffix after you added fields to a form!

Website Baker knows which entries to put in which line because of the session id. So even if multiple users fill out forms at the same time, there will be no mix up of data.

But how about a looping form page, will the same fields from the first child be overwritten with data from the second child? The answer is no, because the function private_function_on_success appends some char to the session id after each loop in your code. Further childs will be written into new rows. When there are 3 children, the session id might look as follows, for instance:

Matching all children of the user is no problem because the first 8 chars of the session id are constant for that user.