cvs: pear /HTML_QuickForm QuickForm.php
| From: | Bertrand Mansion | Date: | Thu, 20 Feb 2003 16:11:22 +0000 |
| Subject: | cvs: pear /HTML_QuickForm QuickForm.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8976@lists.php.net to get a copy of this message | ||
mansion Thu Feb 20 11:11:22 2003 EDT
Modified files:
/pear/HTML_QuickForm QuickForm.php
Log:
Changed the way validation with function is applied:
If element is not required and is empty, it won't be validated against the function.
This makes QuickForm easier to use with other validation packages like Validate and is more
consistent with what is done for regex validation.
Index: pear/HTML_QuickForm/QuickForm.php
diff -u pear/HTML_QuickForm/QuickForm.php:1.62 pear/HTML_QuickForm/QuickForm.php:1.63
--- pear/HTML_QuickForm/QuickForm.php:1.62 Thu Feb 20 05:46:29 2003
+++ pear/HTML_QuickForm/QuickForm.php Thu Feb 20 11:11:22 2003
@@ -17,7 +17,7 @@
// | Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
-// $Id: QuickForm.php,v 1.62 2003/02/20 10:46:29 mansion Exp $
+// $Id: QuickForm.php,v 1.63 2003/02/20 16:11:22 mansion Exp $
require_once('PEAR.php');
require_once('HTML/Common.php');
@@ -1595,6 +1595,9 @@
if (empty($submitValue) && isset($this->_submitFiles[$elementName]))
{
$submitValue = $this->_submitFiles[$elementName];
}
+ if (empty($submitValue) && !$this->isElementRequired($elementName))
{
+ continue 2;
+ }
if (isset($ruleData[2])) {
if (!call_user_func(array($ruleData[2], $ruleData[1]), $submitValue,
$format)) {
$this->_errors[$elementName] = $message;
@@ -1664,7 +1667,7 @@
case 'regex':
$regex = str_replace('%data%', $format, $ruleData[1]);
if (!preg_match($regex, $value)) {
- if ($value == '' &&
!$this->isElementRequired($groupName.'['.$elementIndex.']')) {
+ if (empty($value) &&
!$this->isElementRequired($groupName.'['.$elementIndex.']')) {
continue 2;
} else {
$this->_errors[$groupName] = $message;