Re: QuickForm Validation

From: Date: Tue, 15 Apr 2003 09:34:54 +0000
Subject: Re: QuickForm Validation
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4850@lists.php.net to get a copy of this message
<whovind@web-sters.com> wrote : > Still the same problem. > > First form displays just fine. The 'verify' form with the next and back > work great....the first display of the second form shows validation errors > even though it's the first time being shown. > > Wade > > > > $currentForm[0] = 'form'; > $currentForm[1] = 'form2'; > > // Here test if $currentForm[$_SESSION["step"] exists > > include($currentForm[$_SESSION["step"]].'.php'); > > if(${$currentForm[$_SESSION["step"]]}->validate()) { > $_SESSION['step']++; > include($currentForm[$_SESSION["step"]].'.php'); > } > > ${$currentForm[$_SESSION["step"]]}->display(); Hi Wade, That's normal, it's because you actually call validate(). Just don't call it and errors won't be displayed. So, in the code you've sent me, do: if (isset($_POST['actions']['verify']) && $form->validate()) { Instead of if ($form->validate() && isset($_POST['actions']['verify'])) { As simple as that :) The first form displays fine only because there has not been any posted values so validate() is always false in that case and QuickForm does not actually go any further in the validation process so no errors are displayed. Bertrand Mansion Mamasam

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