The problem is in the class name "Validation" which is the same as the core class name. If you rename it the conflict goes away.
You've got to change two things in the code, first the name of the class in the class definition (file validation.php). The author's name is Evan so I renamed his class eValidation: "class eValidation" on line 26 of Validation.php Don't forget to rename the constructor on line 45: function eValidation(&$data, &$model) Next you have to change the name of the class where it gets instantiated. In app_model.php look for the function invalid_fields that you added and change this line to include your new class name: $validation =& new eValidation($data, $this); it should work now. While we're at it, the other bugs I was talking about occur when the code passes the field to be validated through the _evaluate function twice. Look at this function below: function validatePattern($fieldName, $params) { $pattern = $params['pattern']; return $this->_evaluate(preg_match($pattern, $this->data[$this->name] [$fieldName]), "does not match pattern {$pattern}", $fieldName, $params); } it validates the field against a user-supplied pattern and sends the result to the _evaluate function where the model->validationErrors are set. Good so far. The following function is a convenience function so that you don't have to remember the regex for a valid word: function validateWord($fieldName, $params) { $params['pattern'] = '/^\\w*$/'; return $this->_evaluate(!$this->validatePattern($fieldName, $params), "is not a valid word", $fieldName, $params); } it first runs the field through validatePattern() [which in turn runs it through _evaluate()] and then sends the inverse of the result through _evaluate again, resulting in the opposite answer to what you'd expect. If we follow the logic, for a given field containing valid data, validateWord() calls validatePattern() which calles _evaluate() with "true" as the first parameter (the regex matched for valid data). _evaluate() in turn returns true and so validatePattern() also returns true. now we run _evaluate again with (!true) as the first parameter. this time _evaluate() fails and the error message is set, even though the field is valid. the problem is with the ! symbol that negates the first return value. By simply removing the ! the function returns true as expected and the field validates. This is true throughout the code wherever a convenience function is used to alias a more general function. The second time through _evaluate() - which is done to allow for custom error messages - the validation fails. The following functions need to be changed: validateRequired validateWord validateInteger validateNumber validateEmail validateYear > I was almost tempted to > simply delete the standard Validation class and overwrite it with this > one, but that would cause other problems down the road, I'm sure. Bad Idea Jeans™ ;) Don't touch the core code unless you're using some kind of versioning system that will let you merge in the latest updates or you'll never remember all the places where you made changes. That goes double for now as they're adding new stuff to the trunk every day. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---