cvs: pear /HTML_QuickForm QuickForm.php

From: Date: Sun, 02 Feb 2003 17:44:08 +0000
Subject: cvs: pear /HTML_QuickForm QuickForm.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8688@lists.php.net to get a copy of this message
mansion Sun Feb 2 12:44:08 2003 EDT Modified files: /pear/HTML_QuickForm QuickForm.php Log: Now it is possible to use a class or an object method tho validate an element. Use registerRule('ruleName', 'function', 'classMethodName', 'object'); or registerRule('ruleName', 'function', 'classMethodName', $object); The method should accept 2 parameters: a value and a format. Both can be whatever types. Index: pear/HTML_QuickForm/QuickForm.php diff -u pear/HTML_QuickForm/QuickForm.php:1.56 pear/HTML_QuickForm/QuickForm.php:1.57 --- pear/HTML_QuickForm/QuickForm.php:1.56 Sun Feb 2 11:08:13 2003 +++ pear/HTML_QuickForm/QuickForm.php Sun Feb 2 12:44:08 2003 @@ -17,7 +17,7 @@ // | Bertrand Mansion <bmansion@mamasam.com> | // +----------------------------------------------------------------------+ // -// $Id: QuickForm.php,v 1.56 2003/02/02 16:08:13 mansion Exp $ +// $Id: QuickForm.php,v 1.57 2003/02/02 17:44:08 mansion Exp $ require_once('PEAR.php'); require_once('HTML/Common.php'); @@ -1529,13 +1529,16 @@ } break; case 'function': - if (method_exists($this, $ruleData[1])) { - if (isset($submitValue)) { - $element = $submitValue; - } elseif (isset($this->_submitFiles[$elementName])) { - $element = $this->_submitFiles[$elementName]; + if (empty($submitValue) && isset($this->_submitFiles[$elementName])) { + $submitValue = $this->_submitFiles[$elementName]; + } + if (isset($ruleData[2])) { + if (!call_user_func(array($ruleData[2], $ruleData[1]), $submitValue, $format)) { + $this->_errors[$elementName] = $message; + continue 2; } - if (!$this->$ruleData[1]($elementName, $element, $format)) { + } elseif (method_exists($this, $ruleData[1])) { + if (!$this->$ruleData[1]($elementName, $submitValue, $format)) { $this->_errors[$elementName] = $message; continue 2; }

« previous php.pear.cvs (#8688) next »