Re: Package proposal: HTML_QuickForm_Controller

From: Date: Fri, 29 Aug 2003 10:00:00 +0000
Subject: Re: Package proposal: HTML_QuickForm_Controller
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-20809@lists.php.net to get a copy of this message
<borz_off@cs.msu.su> wrote : > Hi! > > This is an add-on to HTML_QuickForm package which (as the name suggests) > behaves like a Controller from MVC design pattern. It receives the name > of the action from HTTP request data and calls the appropriate handler. > > This is exactly what should be called a subpackage for QuickForm and is > proposed separately because the code is of beta quality and needs > further testing while QuickForm itself is stable. Hi Alexey, Sorry for not replying sooner, I was testing the package thoroughly. All in all, I find it really cool, it makes it easier to have multi-page forms with logic. I was able to make very complex stuff with it. Here are the main problems I met though and they will probably be addressed before the stable release: 1. It's difficult to prepare the form. While buildForm() is handy because it creates the form on demand, sometimes the form creation depends on some external data. There should be a way to pass this external data to buildForm(). For example, options from a select box often come from a database. Maybe a Prepare Action, a parameter for buildForm() or a new init() method would be appropriate ? Unless you have a better solution. 2. File uploads in multiple pages forms are not handled. I have had to extend HTML_QuickForm_Action_Direct to manage uploads. I have used hidden fields to keep track of the filenames once they were uploaded. Then I had to call applyDefaults() when the form page was changed so that the hidden field value was set. We should think of a better way, though this feature will probably cause some difficulties. 3. This lead to another problem with exportValues(). For example, you have a form with a group called 'colors' in which you have elements 'code', 'desc_fr', 'desc_en'. Upon creation, these elements will be called 'colors[code]', 'colors[desc_fr]', 'colors[desc_en]'. Now somewhere else in your code you have a hidden field 'colors[photo]' that is not part of the group. If you use setDefaults() for 'colors[photo]' and then try to exportValues(), it seems to forget about its value. I still have to make a small test case to locate the problem exactly, but my first guess is array_merge_recursive() in exportValues(). I don't know if I am allowed to vote here so I would just say that this subpackage really makes QuickForm easier to use in complex applications and encourage QuickForm users to vote +1 for it. Bertrand Mansion Mamasam

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