Welcome Guest, Not a member yet? Register   Sign In
Multi-Step Form Data
#11

[eluser]maadmac[/eluser]
[quote author="BrandonDurham" date="1194132763"]When creating a multi-step form (specifically a form broken up into three steps/pages) is it a bad idea to create a session variable containing the form data to carry it between pages?[/quote]

No, it's not bad "form" at all... that's precisely why sessions exist. I'm working on exactly the same thing right now, and when it comes to multistep forms, with CI you have basically 3 options:

1. Store the user data as a session cookie
2. Store the user data in the session but write them to the db
3. Treat the multistep form as separate forms, and store each page's results in the db

For #1, this is great so long as you're not storing >4kb. One of CI's limitations is that session userdata are not written to the db, though Mr Allard promises us that this is forthcoming. In the meantime, there are some excellent 3rd party options that will do that, which brings us to #2. I like OBSession, personally, but like many of the best CI developers, Oscar has jumped ship for Kohana and so there is no further development on it.

#3 is my recommendation and is really easy to implement in CI. (walesmd has answered this question like a dozen times in the forum, hunt around a little bit and you'll find it.) In my case, I have a temporary table called 'cart' that stores each page's worth of POST data -- as the user goes page by page, just keep writing it to the table. All you'll need to do is the store the item's ID in the session so you can perform the db lookup. If they want to make any changes, you do it all in that table.

Finally, when everything's ready to go, commit the data in 'cart' to 'orders' and flush the info from 'cart'. So that table acts as a staging area... This is the approach I used for a recent shopping cart-like app and it works simply and easily.

Cheers


Messages In This Thread
Multi-Step Form Data - by El Forum - 11-03-2007, 12:32 PM
Multi-Step Form Data - by El Forum - 11-03-2007, 01:06 PM
Multi-Step Form Data - by El Forum - 11-03-2007, 01:07 PM
Multi-Step Form Data - by El Forum - 11-03-2007, 01:11 PM
Multi-Step Form Data - by El Forum - 11-03-2007, 01:21 PM
Multi-Step Form Data - by El Forum - 11-04-2007, 03:16 PM
Multi-Step Form Data - by El Forum - 11-04-2007, 03:19 PM
Multi-Step Form Data - by El Forum - 11-04-2007, 03:23 PM
Multi-Step Form Data - by El Forum - 11-06-2007, 03:10 PM
Multi-Step Form Data - by El Forum - 11-18-2007, 10:41 AM
Multi-Step Form Data - by El Forum - 11-18-2007, 03:47 PM
Multi-Step Form Data - by El Forum - 11-18-2007, 04:58 PM
Multi-Step Form Data - by El Forum - 11-18-2007, 05:14 PM
Multi-Step Form Data - by El Forum - 11-18-2007, 05:57 PM
Multi-Step Form Data - by El Forum - 11-18-2007, 06:11 PM
Multi-Step Form Data - by El Forum - 11-18-2007, 07:51 PM
Multi-Step Form Data - by El Forum - 01-08-2010, 02:41 PM
Multi-Step Form Data - by El Forum - 08-20-2013, 03:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB