This question is likely to be somewhat longer than SO's average questions, so I'll try to keep it as short as possible:
I'm designing a dynamic form that users need to fill in and submit. This form is massive, with over 500 possible questions. The questions displayed to the user depend on answers given in previous answers (for example; only if the user checks the 'still in school' checkbox, the school-related questions page will show.)
This form has quite a few requirements:
- Multiple pages, which can be 'turned on or off' depending on the answers given.
- When a user goes back and changes a particular answer, filled groups that will be turned off need to have their questions' answers emptied.
- Some questions are pre-filled according to earlier answers given.
- Forms will need to be saved to the database on every new page request, so users can pause and continue filling the form at will.
The best approach to this would seem to be an OO one; define a class that accepts multiple options (title, type of input to be used, possible answers, etc), and builds the HTML accordingly.
The main problem with this approach, however, is that because questions can 'borrow' information from prior ones, it won't suffice to create an instance for just the questions to be displayed on the page. In fact, the only reliable way is to instance every possible question, everytime the user loads a new page.
This approach is likely to kill PHP performance; and to me, it seems like this is not the proper OO solution.
Are there better solutions to this problem?
In essence, I need a fast and lightweight way to create multi-dimensional array of 500 to 1000 records (class instances?), roughly 10 of which will be displayed on a page at any given time.
Preferably, I want to store the form as an XML document, so any approach that would work well in this aspect would be preferred.