Re: QuickForm rule needs other submittedValues
| From: | xavier | Date: | Thu, 22 May 2003 19:30:23 +0000 |
| Subject: | Re: QuickForm rule needs other submittedValues | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5557@lists.php.net to get a copy of this message | ||
Wolfram Kriesing wrote:
i 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? Hi,if it can helps, here is how i implemented that: In QF page: function _ruleuniquemail($element) { global $form; $email = $form->getElementValue('usr_email'); return DO_T_webusers::uniqueMail($email); } In DataObject class: function uniqueMail($email) {
$u = new DO_T_webusers();
$u->get('usr_email', strtolower($email));
if($u->N > 0){
return false;
} else {
return true;
}
}
Regards
--
Xavier
--
Xavier