Re: Re: QuickForm rule needs other submittedValues
| From: | Wolfram Kriesing | Date: | Thu, 22 May 2003 15:53:46 +0000 |
| Subject: | Re: Re: QuickForm rule needs other submittedValues | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5552@lists.php.net to get a copy of this message | ||
Bertrand Mansion wrote:
<wolfram@visionp.de> wrote :those are the only ways!? i believe the expert :-) thanks Bertrand. -- Wolfram ... opensource @ vision:produktion ... http://opensource.visionp.de ... translating template engine .... http://sf.net/projects/simpletpl ... authentication system .... http://sf.net/projects/authi have written a rule, which i register using registerRule(). This rules checks if the email is unique. But what i need for this to properly do the work is the ID, which is another one of the submitted values. But as i see it i have no chance to access any other data of the form from within my rule-function. Or is there a way? this is my rule-function. function isEmailUnique($email) { $user =& new Dao_User(); $user->setWhere('LOWER(email)='.$email); $user->addWhere('id<>'.????user-ID????); return $user->getCount()>0?false:true; } here i need access to other submitted values. is that possible? or how do i do it best?There are different ways to do that. 1. You validate a group, not an element. This way, every values from the group will be passed to the validation function. 2. You use the format parameter of your addRule() method: $form->addRule('email', 'Email is not unique', 'isEmailUnique', $form->getSubmitValue($userId)); then change your function to : function isEmailUnique($email, $userId) 3. You make $form global in your function...