For multiple validation rules on the same field, each failure will
overwrite the existing message with its own message, so in your case,
for usernames, if your validation rules looked like this:

'username' => array(
     'required' => array('message' =>'You must choose a username')
    ,'pattern' => array('pattern' => "/^[a-z0-9]+$/", 'letters and
numbers only')
    ,'length' => array('min' => 5, 'max'=>12, 'message'=>'The username
must be between 5 and 12 characters')
    ,unique' => array('message'=>'that username is already in use')
)

and your user chose Petr as a username, he'd first see the length rule
and when he'd corrected that, he'd get a second error telling him
about the uppercase P. Not ideal, but that's the way it works. Think
about the order in which you want to apply your tests to minimize that
kind of thing.

If you want to show all messages at once, you'd have to hack the
_evaluate routine by concatenating the $params['message']

$this->model->validationErrors[$this->name][$fieldName] .= ' ' .
$params['message'];

This will generate a warning if $this->model->validationErrors[$this-
>name][$fieldName] is not defined so be sure to test using isset() and
then assign(=) or concatenate(.=) accordingly.

What you can't do is have a separate list item for each error because
of the way that the validationErrors array is designed in the first
place.

A workaround could be to add a unique string separator, something that
you know for sure will never appear in an error message, before you
concatenate and then, in the modelErrors routine, explode() the
combined error message based on your special string and then print out
the single messages as individual list items.  I'll leave that as an
exercise for the reader ;)


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to