HTML_QuickForm custom rules

From: Date: Fri, 06 Aug 2004 00:04:26 +0000
Subject: HTML_QuickForm custom rules
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-13977@lists.php.net to get a copy of this message
I want a custom rule that checks the value of a text box is a year between 1970 and $currentYear. However, I am unable to find much documentation either for the PEAR custom rules or for callback functions in general. In my class (which is a subclass of HTML_QuickForm), I have: $this->addRule('firstDegreeCompletionYear', "You must enter a year between 1970 and 2004", 'callback', array($this, 'isBetween()')); then in the same class I have private function isBetween($val) { if ($val >= 1970 && $val <= 2004) { return true; } else { return false; } } Even better would be if isBetween could take 1970 and 2004 as parameters - e.g. $this->addRule('firstDegreeCompletionYear', "You must enter a year between 1970 and 2004", 'callback', array($this, 'isBetween($formVal, $min, $max)')); private function isBetween($val, $min, $max) { if ($val >= $min && $val <= $max) { return true; } else { return false; } }

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