Re: help with quickform, I want to pass more than one parameter to a function rule!

From: Date: Fri, 25 Nov 2005 19:28:35 +0000
Subject: Re: help with quickform, I want to pass more than one parameter to a function rule!
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22079@lists.php.net to get a copy of this message
On 11/25/05, Antonio Luis Batista <albatista@gmail.com> wrote: > |Hi all, > I'm trying to make a form generator using HTML_Quickform, and I have a > problem when registering rules for the form fields, I want to make a > type check(can be multiple types) so I register a function in the form: > $this->registerRule('checkType', 'function', 'typeOK', > &$this); > Well so when I add a field I need to call to my function typeOk with two > parameters: the content of the field and the type that is suppose to be, > so with a call like this: > $this->addRule('field1', 'Tipo no concuerda', 'checkType'); > I cannot pass my type variable to my function, is there anyway of do > it?,I mean pass more variables than the content of the field to my function? > The function should be something like this: > > function typeOk($sField, $sType) > { > //type check depending of $sType > > > > return $bOk; > } > > Since it sounds like you have a limited number of types I would suggest defining a function for each type that calls you checkType function. Something like: function checkInt($value) { return checkType($value, 'int'); } -- Justin Patrin

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