class myUser extends UserModel do not executes ::afterSave() method
dkipkaev opened this issue · comments
dkipkaev commented
Hi. I have the following simple code
class User extends \yii2mod\user\models\UserModel
{
public function getUsermeta()
{
return $this->hasOne(UserMeta::class, ['user_id' => 'id']);
}
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
if ($insert) {
$usermeta = new UserMeta();
$usermeta->link('user', $this);
}
}
}
When creating a new user (config.php
: 'identityClass' => 'app\models\User'
), the function afterSave() do not want to be executed.
Any thoughts to resolve this?
dkipkaev commented
Ok, I found who is responsible for that
public function signup()
{
...
$this->user = new UserModel();
...
return $this->user->save() ? $this->user : null;
}
SignupForm.php