HTML_Quickform - Validation
| From: | Barry Steele | Date: | Mon, 13 Oct 2003 13:05:57 +0000 |
| Subject: | HTML_Quickform - Validation | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-8401@lists.php.net to get a copy of this message | ||
Hi all,
I'm in a bit a quandry, I have a rather large form the has been running
in production now for about a week. It is built with QF/DB_DataObjects.
I just upgraded to RH9 on the server (which happens to be my development
workstation as well).
since then the the validate() function seems to reset the form.
I've run a few tests and its seems that validate() is failing as I would
expect but I don't get any error messages.
I tried puting a debuf statement in the control of the script but that
simply gave me a "Cannot be displayed error"
I had issues with Squid today, after the upgrade to RH9 and this may
infact be the cause of it all.
Code looks like
if ($_REQUEST['incSubmit'] == 'Add Incident')
{
echo "Ok so we are validating the form after Add
Incident<br>";
if ($this->inputForm->validate())
{
echo "Validation done <br>";
$incVals = $this->inputForm->getSubmitValues();
// add submitted data to hidden field(s)
$incidentData = new
HTML_QuickForm_hidden('page1data',serialize($incVals));
$this->inputForm->addElement($incidentData);
if ($incVals['incResus']['incResusFlag'] == 'N')
{
$this->freezeElements("resus");
}
// Remove Incident elements and Rules
$this->removeElements('inc') ;
$template = 'resusForm.tpl';
}
else
{
echo "Huh? ... this shouldn't happen, methinks<br>";
Var_Dump::display($this->inputForm);
$dispFlag = TRUE;
die("Poop");
}
else if ($_REQUEST['Submit'] == 'Add Resuscitation Data')
{
$dispFlag = FALSE;
$this->removeElements('inc') ;
if ($this->inputForm->validate() )
{
echo "Validate Resus form - where too now?<hr>";
return $this->inputForm->getSubmitValues();
$dispFlag = FALSE;
}
}
if ($dispFlag == TRUE)
{
$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl);
$renderer->setRequiredTemplate
(
'{if $error}
<font color="red">{$label|upper}</font>
{else}
{$label}
{if $required}
<font color="red" size="1">*</font>
{/if}
{/if}'
);
$renderer->setErrorTemplate
(
'{if $error}
<font color="orange"
size="1">{$error}</font><br />
{/if}{$html}'
);
//echo $template."<hr>";
$this->inputForm->accept($renderer);
// assign array with form data
$tpl->assign('form', $renderer->toArray());
// render and display the template
$tpl->display($template);
}
}
I am mystfied and after two days of flailing around I'm now really
officially stuck.
www.hpfm.biz
Barry Steele
hpfm solutions pty ltd
Mob: 0413947980
mailto:: barry@hpfm.biz