I'll take that as a challenge then :) The workaround would be quite effective, but not ideal as you say...
One thing I considered, although it's probably not optimal, is to store the messages in another slightly deeper array. So when assigning the error messages, I'd use: $this->model->validationErrors[$this->name][][$fieldName] = $params['message']; Which if I'm thinking correctly about this would produce something like this: array( 'User' => array( 0 => array( 'username' => 'You must choose a username'), 1 => array( 'username' => 'Your username is too short. It must be between 4 and 14 characters'), 2 => array( 'email' => 'Your email address is not valid') ) ); etc... I don't know how effective that would be, and I've not yet developed any code for it so it could be completely wrong. But I might give it a try next week (got a weekend away from coding, lucky me). Thanks Marcel :) On Feb 8, 12:46 pm, "mcgordon" <[EMAIL PROTECTED]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---