[PHPLIB] oohforms & result from validate From: Bob Strouper (bobw123 <email protected>)
Date: 11/10/99

Hello,

Would it not be more appropriate for server side
validate() ( when javascript is OFF ) to return
the error as an array of error mesages rather than
just a single value? As it stands now a separate
visit to the server is required for each error.
( that is if the user only fixes the error that is
printed to the screen)

So if validate() returned an array, one could display
ALL the errors at once:

//sorry my web mail will remove all indents :-(

$error = $f->validate("ok");
if ($error != "ok")
{
echo "<strong>The folowing errors have been found:</strong><br>\n";
while (list(, $val) = each($error))
{
echo "<b><font color=\"red\">$val</font></b><br>\n";
}
}

The changes to the validate() function are small...see the
lines that contain $arres:

function validate($default=false,$vallist="")
{

if ($vallist) {
reset($vallist);
$elrec = $this->elements[current($vallist)];
} else {
reset($this->elements);
$elrec = current($this->elements);
}

while ($elrec)
{
$el = $elrec["ob"];
if ($res = $el->marshal_dispatch($this->method,"self_validate"))
$arres[] = $res;
if ($vallist)
{
next($vallist);
$elrec = $this->elements[current($vallist)];
}
else
{
next($this->elements);
$elrec = current($this->elements);
}
}
if ($arres){ return $arres; } else { return $default; };
}

Please let me know what you think.

-Bob

PS: Kristian, thanks VERY much for your code regarding
my post "input type file: oohforms" !

__________________________________________________
FREE Email for ALL! Sign up at http://www.mail.com

-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.