kylewolfe — 2010-11-11T13:28:49-05:00 — #1
I've been having trouble setting multiple custom errors to the same field. I've made a custom validator to do this for me as it was needed before, but for something like checking valid email it shouldn't be necessary.
I know to change the error message of a required field I'd use 'messages' => array('IsEmpty' => 'errer message here'). And I could use setErrorMessage() but I've only had success of adding 1 error to encompass all errors thus far.
So How might I add IsEmpty error and also a seperate error for ValidEmail
kylewolfe — 2010-11-17T15:13:26-05:00 — #2
Does my question need rephrasing or do I have a stumper? I figure it wold be done with an array inside of addErrorMessages(); but I'm not sure how.
siradrian — 2010-11-17T17:57:06-05:00 — #3
I know that the Email validator is a special case because it also proxies to the Hostname validator. This really complicates the error message change process.
kylewolfe — 2010-11-18T04:51:14-05:00 — #4
Well take another example in its place then. Alnum and NotEmpty for example.
siradrian — 2010-11-18T16:09:23-05:00 — #5
I wrote some examples on a related stack overflow question.
Short answer: pass 'messages' => 'string' to each validator to override per validator.
kylewolfe — 2010-11-18T21:30:20-05:00 — #6
Yes I've tried this. When one error is tripped it shows all errors.