I’m developing on a really bad code-base that is loosely formed around Zend Framework (PHP) so ORMs can’t be used and neither can any other framework. I have attempted using Zend_Form but I found the documentation too sparse (I have developed small forms with Zend_Form but nothing of this size).
I need to create a long form (6 pages long). The user will be able to switch between each step as they please with no validation at all until they attempt to submit the form (not a good idea in my opinion but that’s what the spec says).
At the end of the process, the form will be validated and then the data will be split into a number of different tables in the database. Oh and just to make things fun: there are three versions of this form, all with slight alterations on fields, nothing major. They all store the data in the same tables.
So, what’s the best way to go about doing this? How should I structure it and what would you do if you had to build such a form? I’m writing it in PHP but would like to hear responses from programmers of other languages too. Also if there are any libraries or tools for building such forms, I’d like to hear those as well.
Never done this using ZF, never done such form with validations only when submitting last step, never done a multistep form where user can jump from step to step as they want (I mean jumping from 1st step to 4th, e.g.).
What I did was a 5 step form (where there could be more 3 substeps within 4th step). User can follow the steps one step at a time or go back one step at a time. Each step is submitted and validated – until it is valid user cannot jump to the next step but he still can go back – the values inserted are stored within session. I have created a model (structured class containing other subclasses) so after each step is submitted and valid the data is set into this model that is stored within session.
If You need a really big form where user can jump through steps as he wants, I would consider two ways:
Cannot tell You how difficult will both ways be as I didn’t do such thing using ZF… And hope never will have to.
I would also consider talking to client and explain that validation only at the very last step is kinda foolish and user un-friendly…