Tuesday, September 30, 2008

Re: override built-in validation methods

I frequently override validation functions in AppModel, it works fine
for me.

Put a debug statement inside your AppModel's alphaNumeric method. If
it appears, then the problem is in your regexp/validation handling. If
it doesn't appear, you've probably got a typo in the method name.

Also make sure that your AppModel method prototype matches the 'Custom
Validation Methods' prototype from the manual, as it is NOT the same
as the prototype for Validation::alphaNumeric (first parameter of
model validation methods is an array: { key => value }, parameters of
Validation class methods are all scalar).

Actually, this last one sounds like it might well be the answer.

hth
grigri

On Sep 30, 4:49 pm, "rrd...@gmail.com" <rrd...@gmail.com> wrote:
> Is anyone knows how to properly overrdie a bult-in validation
> function?
>
> I just created in my app_model.php file a function named alphaNumeric,
> the whole function is the same as the built-in, I just changed the
> regex.
>
> Still I get error message:
> Warning (2): preg_match() expects parameter 2 to be string, array
> given [CORE/cake/libs/validation.php, line 830]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: