HTML_QuickForm2: making and_() chained rules non-short-circuited
| From: | Christian Weiske | Date: | Tue, 05 Jul 2011 06:22:57 +0000 |
| Subject: | HTML_QuickForm2: making and_() chained rules non-short-circuited | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-31153@lists.php.net to get a copy of this message | ||
Hi,
When chaining rules (i.e. if email address does not match a certain
schema, then forename and surname has to be not empty), only the first
error is reported because of:
> Evaluation is short-circuited. If first argument of and_() evaluates
> to FALSE then FALSE is returned without evaluating second argument, if
> first argument of or_() evaluates to TRUE then TRUE is returned
> without evaluating second argument.
Is there a way to circumvent that short-circuity?
The semi code of my form is:
$email->addRule('notregex', 'error', '/@foobar.com$/')
->or_($firstname->createRule('notempty', 'error'))
->and_($lastname->createRule('notempty', 'error'));
When the user enters an email address test@example.org and does not
provide firstname nor lastname, only the firstname error is shown. The
user fills it (and still missed the last name), and then the last name
error is shown. I'd like to show both errors at once.
How do I do that?
--
Regards/Mit freundlichen Grüßen
Christian Weiske
-= Geeking around in the name of science since 1982 =-