[Catalyst] Suggestions on how to handle 12 page form

Eden Cardim edencardim at gmail.com
Wed Nov 17 00:31:31 GMT 2010


>>>>> "Eric" == Eric Berg <eberg at bergbrains.com> writes:

    Eric> What about breaking the form up logically and saving each
    Eric> section in a session object as they move through the form.
    Eric> That or incrementally save and maintain a db flag that
    Eric> indicates doneness.  Frankly, with.a form that long, it'd be
    Eric> rude to require the user to start from scratch if they
    Eric> couldn't finish in one session.

Be careful with how you implement it using the session though, if they
give up on the process and come back later, they'll land in the middle
of the previous process and possibly not remember why. Also, if you just
stash the values in the session, you can't do useful things like passing
a URI pointing to a half-filled form for someone else to fill in.

One way to do it and not break HTTP's stateleness that much is to create
a token for each "form fill" attempt, and resubmit it throughout each
page of the form in order to get to the session-stashed data and prefil
the form from it, then the app figures out what's the next step based on
how much of the form is filled. It's basically the same thing as a
regular form except that you write to the session using the token you
got from the current request. At the final step, you commit the data to
the storage and clear the token/data from the session.

If you want to get sophisticated, you can create a new token for each
step and create a linked list of tokens, in order to create a
bread-crumb-like behaviour.

I've been wanting to write a module with that logic for some time now,
but I always find myself lacking the tuits.

-- 
     Eden Cardim            Need help with your perl Catalyst or DBIx::Class project?
   Software Engineer                   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.        Want a managed development or deployment platform?
http://blog.edencardim.com             http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list