I just recently downloaded yii2 advanced template and create new model in frontend module that extend User in "common/models" like this
class UsUser extends User
{
}
class SignupForm extends Model
{
/**
* Signs user up.
*
* @return User|null the saved model or null if saving fails
*/
public function signup()
{
if ($this->validate()) {
$user = new UsUser();
$user->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->generateAuthKey();
$user->save();
return $user;
}
return null;
}
When I signup, there is no error and simply get redirected to main page but no data is inserted into db. I do not use public attribute in my model (either User or UsUser) as specified by Tal V. in here (Yii2 active record model not saving data . So only @property annotation in UsUser.
Maybe I am doing it wrong or is there something else to be aware of, could somebody help pointing it out? Many Thanks.