public function actionIndex() { if (!Yii::$app->user->isGuest) { return $this->redirect(['site/index']); } $model = new RegisterForm(); if ($model->load(Yii::$app->request->post())) { if ($model->register()) { $model->login(); return $this->redirect(['site/index']); } } return $this->render('index', ['model' => $model]); }