QuickForm replacement within

From: Date: Tue, 17 Oct 2006 18:20:28 +0000
Subject: QuickForm replacement within
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25484@lists.php.net to get a copy of this message
A bit ago I emailed the list about possible replacements for QuickForm, but I ended up deciding to code my own. So a few days later, I have something working, and I thought that y'all might be interested in it. It is currently missing some things that I plan on adding, but I've successfully used it in one form so far. It automatically does the standard QF things, like JavaScript, rendering plugins, and validation via custom rules. Some things not included in QF include non-enforced XHTML 1.1 compliance (you can really break it that's your thing, but by default it's compliant), intrinsic rules (select enforces the returned value to be one of its options), nested groups, automatic accessibility features like <label> tags, optgroups, javascript highlighting of errors, and access keys. I've tried to keep the API very similar to QuickForm, but I've removed things that I found unnecessary or redundant. It's also fast, in an email last week I did a quick-and-dirty profile of my code. The total render time using QuickForm was in the ~0.90 second range. Render time for a new identical form, with added rules and JavaScript validation is ~0.52 seconds. Without any form being used, the page takes ~0.38 secs to render. The API used is virtually identical. This isn't intended as any sort of insult to QuickForm developers. I got some things coded that have been in my head for a while, and I kept a close tabs on the QuickForm way of doing things. It's more of a challenge for them to make QuickForm2 at least this powerful. One thing that I particularly like is a customizable rule that I've created (QF2 should have something like this IMHO). Here is it's usage in the form that I made. If the text input is blank *and* a value -2 is selected in the pull down menu, throw an error: $newNameElm->addRule(new Form_Rule_Boolean('%s == "" && %s == -2', 'If you are creating a new area, you must fill in it\'s name.', $newNameElm, $areaElm)); It's a completely free form boolean statement, with an arbitrary number of elements used. It automatically uses the boolean statement to generate code for both client side and server side validation. This example really doesn't show off its power, but I'll let you use your imagination. Download the class here, and tell me what you think: http://pricepages.org/pear/Form.php.zip (Yes, I'm fully aware that it's missing some basic elements, renderers, and rules that come with QuickForm. I'd consider this alpha quality, at best. They will be added as I need them, unless someone else codes them first. ;) ~Seth

« previous php.pear.general (#25484) next »