Re: New package: DB_DataObject_FormBuilder (was: Re: [PEAR-DEV] Re: DataObjectOnSpeed Sum-Up)

From: Date: Thu, 21 Aug 2003 11:46:14 +0000
Subject: Re: New package: DB_DataObject_FormBuilder (was: Re: [PEAR-DEV] Re: DataObjectOnSpeed Sum-Up)
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-20240@lists.php.net to get a copy of this message
Bertrand Mansion wrote:
Here is a suggestion, I don't know how this could be adapted to your package as it seems to extend DB_DataObject. I would like to add a Builder object to the QuickForm package. Its role would be to build the form using addElement() and addRule() calls. It will use helper objects a bit like it is done already in the Config package. So there could be a HTML_QuickForm_Builder_DataObject that would help Builder build its form based on the structure of a DataObject. Do you get the idea ?
I guess, actually until now it sounds pretty much like what my class does. It doesn´t extend DB_DataObject by the way - not anymore. It now takes a DataObject-derived class as a parameter, extracts its structure and settings and builds the form according to that information.
Furthermore, taken into consideration that DB_DataObject could be seen as a mix of a Model and a Controller, and QuickForm as a mix between a Controller and a View, I think your package belongs more to QuickForm than to DataObject.
That depends on how you see it. Arnaud has had the idea that in the future one could create more form building "drivers", for example one for GTK, one for WML ... and then have the base class just analyzing the DataObject and the derived class builds the form definition. In that case, the class would be more in the DataObject side...
Of course, this will need some more work. With Alexey, we have worked a lot on QuickForm lately. We have refactored the validation process to use a new HTML_QuickForm_Validate class that will call HTML_QuickForm_Rule(s) objects, like in the Strategy pattern.
I´m not very familiar with the strategy pattern... is there already something in CVS that you can point me to so that I can have a look?
We have also worked on a new HTML_QuickForm_Controller class that will handle HTML_QuickForm_Page(s) and HTML_QuickForm_Action(s) objects. This will allow for example Wizard like forms, multipage forms and probably more consistency in the processing of forms.
That certainly sounds nice.
As everything is now extendable, there could also be special HTML_QuickForm_Action(s) and HTML_QuickForm_Rule(s) dedicated to work with DB_DataObjects. I hope you see like me how all this could be integrated together nicely.
Indeed, but I would really need to take a look at some Action/Rule objects to see how they work... otherwise I don´t know how easy/complicated it may be to make a DO-specific FormBuilder based on that. Also, I don´t want to lose any flexibility I have now - currently the user can override almost everything by adding properties and methods to his DataObject-derived classes... so I have to ensure this is easily possible in the future as well.
So before you release anything, I would like to know your opinion on this and whether you would like to help us work on a Builder infrastructure.
If the code that I have now is somewhat easy to port to your structure, no problem. But I´d also like some other people´s opinions on this - is it good to tie a FormBuilder for DataObject to QuickForm or have one generic builder that can be extended to make any kind of form definition? Regards, Markus

« previous php.pear.dev (#20240) next »