Hi, I wonder if you guys can point me in the right direction please.
I’m currently building a number of HTML_Quickforms which work fine when run independantly.
All forms have been set up to run validation on the client side (i.e. java pop up boxes).
When I process them in the same php script, the first form works just as expected. The second form loads but all validation messages are being displayed as processed on the server side (i.e. red warning messages over specific input fields) at time of initial form display.
If I continue to populate the second form and hit submit - then the java pop up boxes appear as expected.
Are you aware of any way to “purge” the validate() function when processing the second (or more) forms so the form appears for the first time without the server side red warning messages ?
The second form is generated based on successful submission of the first form (in my example below - on the field ‘dd_p1’)
My current code is a follows :
/* ============ FORM 1 ============= */
if (isset($_GET[‘add’]))
{
require_once ‘HTML/QuickForm.php’;
$form = new HTML_QuickForm(‘DD_P1’, ‘post’, basename(FILE));
$opts = array(‘size’ => 20, ‘maxlength’ => 350);
$form->addElement(‘text’, ‘first_name’, ‘First Name’, $opts);
$form->addRule(‘first_name’, ‘You must enter your first name’,
‘required’, null, ‘client’);
$form->addElement(‘submit’, ‘dd_p1’, “Submit Details”);
if ($form->validate())
{
// Form Validates
$formsource = $form->toHtml();
}
else
{
$formsource = $form->toHtml();
include ‘display_form.html.php’;
exit();
}
}
/* ============ FORM 2 ============= */
if (isset($_POST[‘dd_p1’]) and $_POST[‘dd_p1’] == ‘Submit Details’)
{ // build new form
$form = new HTML_QuickForm(‘DD_P2’, ‘post’, basename(FILE));
if ($form->validate())
{
// Form Validates
$formsource = $form->toHtml();
}
else
{
$formsource = $form->toHtml();
include 'display_form.html.php';
exit();
}
}
Thanks for any advice…