Topic: Very long forms, pagination and storing intermediate input

Is it possible to paginate a very long form?  I have a form that is very long and I would like the user to be able to fill out the form one part at a time. 

The sequence should be something like this:

(form input [next]) -> (form input [next]) -> ... -> (form input [create])

The create method will only be called at the very end.  How do you store the intermediate data until the user finishes the last part of the form input and the record is finally saved?

Re: Very long forms, pagination and storing intermediate input

Excellent question. Unfortunately I don't have a good answer.

See this thread for some related information.

There are several ways you can accomplish this. Which way is the best depends on how you want the application to behave. How do you want to handle validation? If someone stops halfway through, do you want a partially filled record in a database? Do the fields/options change depending upon what he chose in the preivous page?

Railscasts - Free Ruby on Rails Screencasts

Re: Very long forms, pagination and storing intermediate input

You could take a look at acts_as_wizard. I have not tried it yet, but I will at some later point.

Thinking about it, I would probably have the "Next" buttons post the data to the server, which creates a model object with the supplied data and stores it in hidden fields in the next form.

The thing is, you'd need to partially validate the model for the supplied parts of the data. One possibility is to create additional models for each page which only validate the parts of the original model that the current form supplies. Then, the "master model" would validate all data when you create is called.

Re: Very long forms, pagination and storing intermediate input

Thanks for your input.  I have implemented this feature currently by posting each form and using a bunch of hidden form elements. The hard part is validation.  At the moment if there are validation errors I display the entire long form.  This is less than ideal.