Breaking up a form across multiple pages in CakePHP
Tuesday, April 21st, 2009Most CakePHP form examples present all the fields on one page and assume users fill everything out at once. But there may be a time when you need to spread a model’s form fields over multiple pages.
This approach brings with it a few important requirements.
1. You should allow the user to go forward and back through the pages to see their input and allow for editing.
2. You should not be able to manipulate the URL to skip ahead.
3. There should be a progress indicator (ie. step 1 of 4, step 2 of 4, etc).
4. The final page should summarize all the info input by the user.
This example came from a recent project where I couldn’t use temporary tables to store my data across the pages. I was also using CakePHP’s Tree behavior on some pages and was reluctant to store the data hierarchy in session variables. So below is an explanation of how I did it just reading in and out of one model. I also provided a working demo.





