Please tell me the sequence of this action ...

public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { $user = $model->signup(); if ($user) { if ($model->shouldBeActivated()) { Yii::$app->getSession()->setFlash('alert', [ 'body' => Yii::t( 'frontend', 'Your account has been successfully created. Check your email for further instructions.' ), 'options' => ['class'=>'alert-success'] ]); } else { Yii::$app->getUser()->login($user); } return $this->goHome(); } } return $this->render('signup', [ 'model' => $model ]); } 

    1 answer 1

    In my opinion this is the standard Yii2 method, slightly modified, if a GET request displays the registration form, if a POST request hits, then the data is validated:

     $model->load(Yii::$app->request->post())) 

    Then create a user:

     $user = $model->signup(); 

    If you need to confirm registration:

     if ($model->shouldBeActivated()) { 

    Then we display a message that check the email, if you do not need to confirm - authorize.

    Everything.