CModel::addErrors() (in plural)

I think a addErrors() function to CModel would be handy.


Let's say you have written a complex form model.  Let's say it's logic is using 3 other ActiveRecord classes. 

Now, when a error is encountered while saving any of those 3 ActiveRecord classes, we need to get that error to the web user.

At the moment, the only way possible is to:

foreach ($someActiveClass->getErrors() as $attribute => $errors) {

        foreach ($errors as $error) {

                $myForm->addError($attribute, $error);



Another way of implementing similar functionality would be to allow CModel to

“register an error handler” so we could do something like this:


And all errors would be registered into $myForm (and perhaps $someActiveClass too).

Or is there already a way to do something similar in Yii ?

A patch that would implement both version is attached, but it’s UNTESTED. Have to run but decided to finish this post …

Could you please create a ticket for this? Thanks.

Done :)

With a tested patch, see ticket…s/detail?id=224