[QuickForm] addFormRule
| From: | Justin Hendrickson | Date: | Tue, 26 Aug 2003 15:32:39 +0000 |
| Subject: | [QuickForm] addFormRule | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-7421@lists.php.net to get a copy of this message | ||
I'm currently using (and very pleased with) QuickForm for all my form display and processing
needs, but today, I've run into a new need that would appear to be supported by QuickForm, but
doesn't seem to work quite right. I'm trying to use the ->addFormRule () method, but
the callback I pass never seems to be called. Here's a sample bit of code to show the basic
idea:
<?php
require_once 'HTML/QuickForm.php';
$qf =& new HTML_QuickForm ();
$qf->addElement ( 'header' , 'test' , 'Test' );
$qf->addElement ( 'text' , 'one' , 'One' );
$qf->addElement ( 'text' , 'two' , 'Two' );
$qf->addElement ( 'submit' , 'submit' , 'submit' );
$qf->addFormRule ( 'testRule' );
$qf->validate ();
$qf->display ();
function testRule ( &$values , &$files )
{
echo "<pre>";
print_r ( $values );
print_r ( $files );
echo "</pre>";
}
?>
Since there's no documentation available for this function, I reviewed the source and it would
appear the problem is the validate () function. It seems that the conditionals at the beginning of
this method skips the validation of the form if there are no $this->_rules, but there is no check
pertaining to the $this->_formRules array. Is this the intended behavior or an oversight?
Justin Hendrickson, Programmer
Klein Internet Marketing Group
a Division of Keith Klein & Associates, Inc.
We design, produce, program, host & market
internet websites.
22603 West Main Street Sussex, WI 53089
justin@onyourmark.com
http://www.kleininternet.com
Phone (262) 820-8201 Fax (262) 820-8202
Toll Free 1-800-747-3399