[Solved] Cake PHP validation error not shown although existing in array [closed]


I found the solution.
I got back to validate within appmodel which is more consistent.

Cake wants the custom validation rules to be in the certain class where the rule is called. So, when you call a custom rule in class post, the custom function has to be written down in class post, otherwise cake won´t find it and validate it to false everytime.

The magic to do here is to import the appmodel-class you want to use in the class you call the validation-function. That works with the following statement:

$Zipcode = ClassRegistry::init(‘Class to use – in my case “Zipcode”‘);

But if your tables are associated with each other with hasAny or belongsTo and stuff, the custom functions works without that. Another important point you mustn´t miss is, that all validation functions has to be introduced with “public function xyz” otherwise cake won´t find them too.

solved Cake PHP validation error not shown although existing in array [closed]