Re: Complex server-side rules with QuickForm
| From: | James Carr | Date: | Wed, 23 Mar 2005 22:59:44 +0000 |
| Subject: | Re: Complex server-side rules with QuickForm | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18295@lists.php.net to get a copy of this message | ||
Josh,
Well, what I normally do (as I have quite a few web applications with
all kinds of javascript features for the UI) is add either an onclick,
onmouseover, etc attribute like described above, or (to make things
simpler), use custom attributes (defined in an extended doctype, of
course!) and have seperate javascript files to work with those.
Of course, you could always just subclass QuickForm and roll your own
custom Rules, or even DHTML extras (which would without a dobt bloat
quickform). I prefer to keep most of my UI related javascript seperate
from the server side code, but YMMV.
Cheers,
JC
On Wed, 23 Mar 2005 13:09:07 -0500, Joshua Beall <jbeall@heraldic.us> wrote:
> > -----Original Message-----
> > From: Justin Patrin [mailto:papercrane@gmail.com]
> > Sent: Wednesday, March 23, 2005 13:06
> >
> > On Tue, 22 Mar 2005 16:58:11 -0500, Joshua Beall
> > <jbeall@heraldic.us> wrote:
> > > Hi All,
> > >
> > > I am wanting to do "complex" server-side JS validation. I put
> "complex" in
> > > quotes because complex is of course in the eye of the beholder.
> >
> > Ok, first thing. "server-side" and "JS" are mutually exclisuve.
> > Server-side rules are PHP and client-side rules are JS.
>
> Yikes, that was a nasty typo. I meant client-side.
>
> >
> > Sounds more like you want some DHTML, not validation. You can easily
> > add an onChange for the select box using:
> > $el->updateAttributes('onchange' => 'someJSFunction(this)');
> >
> > If you want to validate that as well, the easiest way is with a
> > formRule, which would be server-side only.
> >
> > function validateSomething($values) {
> > //return true or array with error message(s)
> > }
> > $form->addFormRule('validateSomething');
> >
> > If you want to add custom JS validation I think you need to create a
> > new rule type (class), register it, and add it to your form.
>
> I understand all that, I just was wondering if QuickForm had some sort
> of builtin functionality to handle the situation I described.
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>