Re: Quickform Validation not occuring
| From: | Adam Hubscher | Date: | Sun, 05 Dec 2004 20:57:51 +0000 |
| Subject: | Re: Quickform Validation not occuring | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16024@lists.php.net to get a copy of this message | ||
if ($this->validate()) {
$this->process('ProcessNewUser',FALSE);
}
else{
$this->addElement('text','account','Desired Login (Max 10
characters):',
array('size' => 17, 'maxlength' => 13));
/*$pass['password'] =& $this->createElement('password',
'password', null,
array('size' =>17, 'maxlength' => 10));
$pass['verify'] =& $this->createElement('password',
'verify', null,
array('size' => 17, 'maxlength' => 10));
$this->addGroup($pass, 'password', 'Password (Desired, Verification):',
'<br />');*/
$this->addElement('password', 'password', 'Desired Password: ',
array('size' =>17, 'maxlength' => 10));
$name['last'] =& $this->createElement('text', 'lastName',
null,
array('size' => 17, 'maxlength' => 10));
$name['first'] =& $this->createElement('text', 'firstName',
null,
array('size' => 17, 'maxlength' => 8));
$this->addGroup($name, 'name', 'Name (last, first):',
', ');
$this->addElement('date','birthday','Birthdate',$this->bdayoptions);
$this->addElement('text','question','Secret
Question:',array('size'=>17,
'maxlength' => 20));
$this->addElement('text','answer','Question
Answer:',array('size' => 17,
'maxlength' => 20));
$this->addElement('reset', 'reset', 'Clear Form');
$this->addElement('submit', 'btnSubmit', 'Submit');
print_r( $this->getRegisteredRules());
$_SESSION['ViewType']='';
$this->applyFilter('__ALL__', 'trim');
//$this->addGroupRule('password', 'Password is required',
'required');
//$this->addGroupRule('password', 'The passwords do not match',
'compare');
$this->view = new View;
$this->view->NewUser($this);
}
This is the code for the block that generates the form. Do i place the
reference as $this->view->NewUser(&$this);? I attempted that and it gave me
the deprecated reference warning, so I suppose I'm just not understanding
where exactly the reference should be placed.
"Alexey Borzov" <borz_off@cs.msu.su> wrote in message
news:41B372CB.9070509@cs.msu.su...
> Hi,
>
> Adam Hubscher wrote:
> > After testing, which included placing the addRule statement everywhere I
> > could think of it being read before the form is displayed... adding a
little
> > piece of code that returned true whenever the addRule function completed
> > successfully... and even testing if the rule is actually added in the
first
> > place, I discovered that although the addRule function is being called
and
> > completing successfully, there is no actual rule being added. (this is
> > assuming that the isElementRequired method does in fact check to see if,
> > say, the 'LoginID' textbox is a required form element based upon the
form's
> > rules). So in this, I discovered that the form validation... was being
> > validated because there were no rules for it to validate.
>
> Most probably you pass the form object into some function not by
reference.
> Therefore the rules are added to the copy of the object and are lost when
the
> function is finished.