I’ve run into the same problem and created a change request on the google code Yii project, but Qiang has denied my request.
I’ve simply overridden the __constructor in my class like this:
class UserModel extends CActiveRecord
{
...
public function __construct($scenario='insert')
{
parent::__construct($scenario);
// Fix problem for creation by instantiate()
if($scenario===null){ // internally used by populateRecord() and model()
$this->init();
$this->attachBehaviors($this->behaviors());
$this->afterConstruct();
}
}
...
}
As you can tell from this code fragment the attachBehaviors and afterConstruct are also not called by the default constructor when calling the model() method.
Here’s the answer he added when closing my request:
I wasn’t satisfied with this answer but have been too busy to work on my project, therefore I never reacted on this mail (maybe I’ll do so, later, sometime).