Hi,
Here's a question to those who take the OO approach in PHP5.
I'm trying to implement a form with multiple parts.
The user fills in one part then clicks 'next'.
The user fills in the next part then clicks 'next' and so on until they reach the last part.
When they have filled that in, they click submit and the data is used to retrieve data from the database or used as input to the database.
How would you recommend applying the MVC pattern to this application or is this the wrong approach?
An initial idea is to have one view class for the whole form (every step). When one part is posted, the part is posted and the controller uses this value to work out which part to show next (after checking that the previous parts were filled in properly). What are everyone's thoughts on this?
Thanks for any feedback.
Multipart forms
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I just answered a question like this here --> viewtopic.php?p=296817#296817. Of course, that is procedural style, but I am sure you can adapt that to whatever style you want to code in. For me, simple is best. But if you want to throw some PHP5 OOP at it, code away.
Just make sure you post your code here so we can all gank it.
Just make sure you post your code here so we can all gank it.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
The pattern for this is called the Application Controller. It is what is used for wizard type page sequences. It is the hardest controller to write because it is usually a state machine of some sort internally. At its simplest you can just store the pages that have been completed in the sequence in the session. You then have logic/rules that use that information to control access to what the user can view -- in addition to the logic/rules for each form.
(#10850)
Here is a few example how they might work
http://www.pradosoft.com/demos/quicksta ... ols.Wizard
http://xisc.com/demo/prado/examples/wizard.php
http://www.pradosoft.com/demos/quicksta ... ols.Wizard
http://xisc.com/demo/prado/examples/wizard.php