nloding Posted August 26, 2008 Share Posted August 26, 2008 So I'm trying to decide on what to do here. Basically I have a site with many different forms -- different types of request forms, different types of user management forms (change password, add user, delete user), etc. Some can be generally linked together, some can't. So I'm trying to find a good way to do this. Being new to OOP design, I'm confusing myself a bit and looking for advice. I had originally thought about an individual class for each form that derives from a base class. The base class would have the parts that all the forms would need -- open the db connection, validate an entry, whatever. But each individual form class would have it's own unique processing details. Then I thought about make some of the forms more dynamic -- in the Admin panel, but the add/change user forms into one form that dynamically updates the fields with Ajax based on whether the add or change radio button was clicked. That situation seemed to negate the classes proposed above. But maybe some sort of factory could determine what kind of form was posted. Any thoughts on this? I'm looking for some scalable and flexible -- more importantly scalable, as we're looking to do a lot on this site ... Thanks! --Nathan Link to comment https://forums.phpfreaks.com/topic/121462-oop-form-processing/ Share on other sites More sharing options...
emehrkay Posted August 27, 2008 Share Posted August 27, 2008 You could create a factory. Set a hidden var with an array of different form types - contact info, settings, etc - then loop through it and run the appropriate class against your $_POST and return your errors in an array... If you do it correctly, you can even use the same factory for your ajax-based requests Link to comment https://forums.phpfreaks.com/topic/121462-oop-form-processing/#findComment-626944 Share on other sites More sharing options...
nloding Posted August 29, 2008 Author Share Posted August 29, 2008 I'm working on a factory for this now. But how would it need to be different to accommodate AJAX requests? Link to comment https://forums.phpfreaks.com/topic/121462-oop-form-processing/#findComment-629100 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.