Forums

Handling Session Data on a Multi-Page Form

luxhodge 08 Oct, 2013
Hello!

I am creating a multi-page order form that does the following:
1. Takes a client's zip code and looks up the latitude and longitude values for it from a DB table then calculates the distance from the client to service providers.
2. Once I know the distance to the service providers from the clients, I sort the $forms->data array in ascending order from closest to farthest from the client.
3. Next I want the client to choose the service provider they want (I show them 3 right now, but I will probably show them 10 when I am done).

Now I want to maintain the client data (their name, address, reason for service and service provider choice along with the array of service providers) throughtout the form. I would rather use a multi-page form for simplicity on the back end, but right now I have all the data from page 1 to page 2. Then when I go from page 2 to page 3 I lose all the service provider data and client data. I looked at the FAQ and went throught he multi-page form explanation, but I can't find the problem. I am sure it is with the session to data and data to session functions, but I need some help and clarification on that if possible.

Does any of this make sense? I think what I am trying to do is very possible. My knowledge is just lacking. Any help you can give me would be great. Attached is a backup of my form. Thanks!

Erik
GreyHead 08 Oct, 2013
Hi Erik,

I don't have the DB Tables so can't test the form beyond the first page.

On the Pge3 action you have a Data to Session action followed by a Multi Page action. I don't think that you need both and I suspect that the Data to Session action is over-writing any data that is already in the session (set Merge Data to Yes to avoid this).

I also looked at the Custom Code in the DB Multi Record Loader and I'm not clear if enough of it is being added to the $form->data array???

Bob
luxhodge 09 Oct, 2013
Thanks again for your quick reply! You are amazing. Definitely buying you a beer shortly.

I attached the two table export CSV's if you want to try importing them and trying the form. I took off the Data to Session on page 3 and left the Multi-page function. It does pass the client entered data (first name, last name, zip code, date requested and the answer to the page two radio button selection). However, I lose the array data that I formed from the multi-record load on page 2. I can see from the debugger function that my array on page two has all the my data. Maybe I have to commit this to the session in my PHP code? I thought it would be included in the data once I loaded it from the multi-record function. Sorry. Not very well versed in sessions yet. Let me know what you think. Thanks a ton!

Erik
luxhodge 09 Oct, 2013
Bob,

Here is a screenshot of an debugger printout on page 2. You can see that the appraisers array is full from the multi record load. It is this data that I am losing from page 2 to page 3. How do I get that data saved to the session so that it is available on page 3 for me to use?
GreyHead 09 Oct, 2013
Hi Erik,

Thanks for the data but the CSV files are too much hassle to import as I'd have to build tables first. If you send MySQL dumps I may try.

If the data is in the $form->data array then it should be saved by a later Data to Session action. I suspect that the problem may be the sequence of actions in the event but I'm far from sure. You could always add custom PHP to save and recover the array separately - that might be simpler than debugging the Data/Session actions.

Bob
luxhodge 09 Oct, 2013
Thanks! I think I will go the custom PHP route. I appreciate your help!

Erik
luxhodge 09 Oct, 2013
Bob,

I gave it one more try, and yes a good night's sleep does wonders for your brain! I moved the DB actions to before the multi-page and data to session actions in the event. The data is now saved all the way through. Awesome! Thanks again and enjoy the beer I bought you! What flavor? I tend towards Guiness and Porter. Enjoy!

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