HTML_QuickForm DHTML client rules and SoftRequired rule
| From: | Justin Patrin | Date: | Sun, 26 Mar 2006 07:54:25 +0000 |
| Subject: | HTML_QuickForm DHTML client rules and SoftRequired rule | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-41978@lists.php.net to get a copy of this message | ||
At the request of a user I've made a QuickForm class which alters the
client rule system to display errors with each field, much like
QuickForm's default renderer normally does upon submission. (Note that
I didn't try to make it *perfect*, I was just trying to get it to work
;-) It also supports running client rules when a field loses focus,
its value changes, or a key is pressed. For this last to work you have
to call getValidationScript() before your form is rendered.
The way that this works depends a bit on the normal renderer, but a
user could easily create divs to put the errors in a specific place.
I've also looked again into the idea of a SoftRequired rule which
makes an error show up the first time a user tries to submit a field
without a value, then goes away if the form is submitted again. I
tried before to create this as a normal QF rule, which is nearly
impossible given QF's limited rule system. However, this time I
limited it to a client rule and it works just fine (albeit with a
simple hack to simulate a static variable).
http://pear.reversefold.com/qf_DHTMLRules_and_SoftRequired.php
Let me know what you think.
--
Justin Patrin