/** @inheritdoc */ public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if ($insert) { if ($this->_profile == null) { $this->_profile = Yii::createObject(Profile::className()); } $this->_profile->link('user', $this); } }