Re: Custom rule not getting validated

From: Date: Mon, 10 Oct 2005 06:20:20 +0000
Subject: Re: Custom rule not getting validated
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21306@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Mon, Oct 10, 2005 at 09:42:50AM +0400, Alexey Borzov wrote: > >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. > Is there any way to get it to "qualify"? Is it simply a matter of inserting something into $form->_required? Do I need to register the rule in some special way in order for QF to recognise it as a required rule? I thought subclassing Rule_required would be sufficient, but I guess not. > I suggest explicitly adding a 'required' rule and a new custom rule which > will do additional checks. Thank you. I have perpetrated this hack, and it works! It seems redundant to me to have 2 required rules, but as long as it works I'm happy. I've also made my customrequired into a 'client' rule, where it works just fine even without any "qualified" required rule present. - -ken - -- - --------------- The world's most affordable web hosting. http://www.nearlyfreespeech.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFDSggke8HF+6xeOIcRAqurAKCxe2TLBpQp1TGl6ff9LgOf+7bh7ACePWug mXSDXaQOvCka9ZoejSatE6E= =3l53 -----END PGP SIGNATURE-----

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