[phplib-dev] cvs commit From: uw (phplib-dev <email protected>)
Date: 01/09/01

From: uw
Date: Wed Jan 10 02:00:34 2001
Modified files:
      php-lib/php/form/form.inc

Log message:
validate() bug fix.

Index: php-lib/php/form/form.inc
diff -u php-lib/php/form/form.inc:1.20 php-lib/php/form/form.inc:1.21
--- php-lib/php/form/form.inc:1.20 Mon Jan 8 02:05:27 2001
+++ php-lib/php/form/form.inc Wed Jan 10 02:00:32 2001
@@ -26,7 +26,7 @@
 * - tree (select box with options show as a tree)
 *
 *  <email protected> Ulf Wendel <ulf.wendel <email protected>>
-*  <email protected> $Id: form.inc,v 1.20 2001/01/08 01:05:27 uw Exp $
+*  <email protected> $Id: form.inc,v 1.21 2001/01/10 01:00:32 uw Exp $
 *  <email protected> public
 *  <email protected> Form
 */
@@ -670,19 +670,26 @@
         * Validate a form.
         *
         *  <email protected> mixed $vallist
+ *  <email protected> form_error
         *  <email protected> array($error_msg, $error_flags)
         *  <email protected> public
         */
         function validate($vallist = "") {
+
+ if ($vallist && !is_array($vallist))
+ $vallist = array($vallist);
 
+ if (!$vallist)
+ $vallist = $this->getElementnames();
+
+ foreach ($vallist as $k => $element)
+ if (!$this->elementExists($element)) {
+ $this->err = new form_error("Unknown element '$element'", __FILE__, __LINE__);
+ return array("", "");
+ }
+
                 $this->validation_msg = "";
                 $this->validation_flags = array();
-
- if (!is_array($vallist) && isset($this->elements[$vallist]))
- $vallist = array($vallist);
-
- if ("" == $vallist)
- $vallist = $this->getElementnames();
 
                 foreach ($this->getCustomValidators($vallist) as $k => $validator)
                         $this->${validator}();

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>