Re: HTML_QuickForm2: Form rule to validate a combination of two fields

From: Date: Sun, 13 Jun 2010 13:07:34 +0000
Subject: Re: HTML_QuickForm2: Form rule to validate a combination of two fields
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30614@lists.php.net to get a copy of this message
Hi Christian, On 12.06.2010 13:38, Christian Weiske wrote:
I have a "you forgot your password" form containing: - Username field - Email field - Captcha - Submit button Both username and email input elements have several rules attached that validate the respective values. Now I want to create a rule that validates that the username-email combination really exists. At first, I added a form rule callback so I get all form value passed. There I can validate username and email myself. The problem I am facing is that the rule gets called even if the fields themselves are not valid. That means I have to do validation of username and email values in my form rule callback method; something that doubles much code. Is there a solution to that problem? Can I get the form rule called only when the fields are valid?
A good catch: the Rules on Containers are called before the Rules on the elements they contain, so you can't really check whether the elements are valid... We should probably change that order, form rules in HTML_QuickForm were called last, after all element-specific ones.

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