Re: HTML_QuickForm DHTML client rules and SoftRequired rule
| From: | Justin Patrin | Date: | Sun, 26 Mar 2006 23:32:37 +0000 |
| Subject: | Re: HTML_QuickForm DHTML client rules and SoftRequired rule | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-41989@lists.php.net to get a copy of this message | ||
On 3/25/06, Justin Patrin <papercrane@gmail.com> wrote:
> 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.
>
I've just altered the class a bit to get rid of this requirement. I
overrode the display() method so it calls getValidationScript()
itself. If you don't use display() you'll still have to add the extra
call to set up the JS event handlers.
> 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
>
--
Justin Patrin