Re: Your opinion about QuickForm2 API
| From: | Gregory Beaver | Date: | Mon, 16 Apr 2007 17:30:38 +0000 |
| Subject: | Re: Your opinion about QuickForm2 API | ||
| References: | 1 2 3 | Groups: | php.pear.dev php.pear.general |
| Request: | Send a blank email to pear-dev+get-46257@lists.php.net to get a copy of this message | ||
Bertrand Mansion wrote:
>> Another feature request I've had that may be possible is to integrate
>> some kind of forms creation cache, so that the form need only be created
>> programmatically once, and then it can on subsequent requests be quickly
>> recreated from a disk or database cache, skipping all the expensive
>> method calls, but this is a separate question than the one you asked,
>> let me know if you'd like a feature request opened on this.
>
> At the moment, I have no idea how to do that, any ideas would be welcome.
> The good news is that QuickForm2 should be faster than current QuickForm :)
Hi Bertrand,
I would store element validation information in a simple array, and then
use the renderer to render a PHP-based template (a la Savant) that will
allow setting default values, so that the display process is basically:
<?php
$form->prepareCache();
include $form->getCacheFile();
?>
Validation would work as it currently does. You'd end up with something
like:
<?php
$form = new HTML_Quickform2;
$form['name'] = 'whatever';
if ($form->submitted && $form->valid) {
}
if ($form->cached) {
$form->displayCache();
} else {
// set up the form
}
?>
Things like validation errors can be handled with placeholders as well
(an if() in the template that skips the error HTML).
Greg