Re: Package proposal: HTML_QuickForm_Controller

From: Date: Fri, 29 Aug 2003 12:01:16 +0000
Subject: Re: Package proposal: HTML_QuickForm_Controller
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-20815@lists.php.net to get a copy of this message
Hi! Bertrand Mansion wrote:
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.
Don't get you here. Even if we make a 'prepare' action, then its handler will have to query this external source. What's the difference from quering it from inside buildForm()?
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.
The problems, as I see them: 1) You can't set the default value for <input type="file" /> element. 2) PHP automatically clears the uploaded file after the request if you do not move it somewhere. So you'll basically have to: 1) Move the file somewhere. 1a) Handle garbage collection in this "somewhere" 2) On return to the page, show the uploaded file data alongside the <input type="file" /> element. 2a) "Uploaded file data" really depends on file type. If you uploaded the picture for example, then it's good to show it. As you can see, the solutions are application specific. And the question is: can they be made generic enough to push them into the package?
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().
OK, this seems to be a QuickForm problem then (I was really surprised that no one have found any bugs in exportValues() yet). :]

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