Addformrule
| From: | zia mohaddes | Date: | Wed, 26 May 2010 20:46:19 +0000 |
| Subject: | Addformrule | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-30577@lists.php.net to get a copy of this message | ||
Hello,
I have previously posted a question on how to create a customize rule. And I
have followed/created a customized rule as described in a response email as
follows:
$this->addNumericElement("q3_1_weight_1",$this->indent.
"Weight in Kg");
$this->addNumericElement("q3_1_weight_2",$this->indent. "Weight in Kg");
$this->addNumericElement("q3_1_weight_3",$this->indent. "Weight in Kg");
$this->form->addElement("static",null,null);
$this->form->addFormRule(array(&$this,'checkQuestions'));
function checkQuestions( $fields ) {
$difference = abs(intval($fields['q3_1_weight_1']) -
intval($fields['q3_1_weight_2']));
if(( $difference <= 200 ) || strlen( $fields['q3_1_weight_3'] ) == 0 ) {
$errors['q3_1_weight_3'] = 'Question 3.1 is required if first and second
part are differed by more than 200 kg';
}
//return $errors;
return count( $errors ) > 0 ? $errors : true;
}
however not only that the rule is not working but I am getting this error:
"QuickForm Error: nonexistent html element"
Not very sure why! Does anyone know why??
Thank you kindly for your time and help in advance!
regards,
zia