I think a addErrors() function to CModel would be handy.
Argument:
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:
$someActiveClass->setErrorReceiver($myForm);
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 …