Re: [QF] Question regarding registration of rules
| From: | Helgi | Date: | Wed, 07 Jan 2004 13:46:03 +0000 |
| Subject: | Re: [QF] Question regarding registration of rules | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-10032@lists.php.net to get a copy of this message | ||
Ahh thanks both Bertrand and Mike :)
On Wed, 2004-01-07 at 13:39, Bertrand Mansion wrote:
> <helgi@trance.is> wrote :
>
> > Hi there
> >
> > Is there any possibility to add a object as my defined rule ?
> >
> > I have a class and i want to use a function that's in that class to
> > validate
> > from in a few forms ( so ofcoz it's best to have the function in one
> > place for
> > better update :) )
> >
> > This function works if a take it out of the class and have it with each
> > form
> > ...
> > But if i try
> > $form->registerRule('userexists', 'callback',
> > '$user->userExists'); then
> > i just
> > get a error
> >
> > Fatal error: Call to undefined function: $user->userexists() in
> > /home/dufuz/public_html/testing/pear/HTML/QuickForm/Rule/Callback.php on
> > line
> > 70
> >
> > And i asume by the error that callback doesn't support objects :)
> >
> > But is there any way around this ?
>
> There is an optional 4th paramater to registerRule() that lets you specify
> in which class the method can be found.
>
> $form->registerRule('userexists', 'callback', 'userExists',
> 'MyUserClass');
>
> Bertrand Mansion
> Mamasam
>