Re: Custom rule not getting validated
| From: | Alexey Borzov | Date: | Mon, 10 Oct 2005 05:42:50 +0000 |
| Subject: | Re: Custom rule not getting validated | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21304@lists.php.net to get a copy of this message | ||
Hi,
Ken Restivo wrote:
I have a custom QF rule: require_once('HTML/QuickForm/Rule/Required.php'); class CustomRequired extends HTML_QuickForm_Rule_Required { } // end class CustomRequired And yet..... guess what? I call validate() on this form, this very same form with a valid rule present and all the above stuff in its QF object vars, and the validate() method on it is never called. I know that because of the big honking raiseError() I stuck in there. The form validates, even with empty fields. That method is *not* ever being called. For *text* fields. On selectboxes, my customrequired::validate() method *is* getting called. So, I know the thing works, my paths are correct, etc. Why would it refuse to work only on text fields? Other validations (a date regexp rule, a form rule) *are* being called on this same form. But not customrequired, on these text fields. Why? Where would I even look to find out why?This is somewhat documented: if the element is empty, and there is no 'required' rule defined for it then other rules will not be called. Your CustomRequired rules does not qualify as 'required' and therefore is not called. I suggest explicitly adding a 'required' rule and a new custom rule which will do additional checks.