Skip to content

Instantly share code, notes, and snippets.

@pzzrudlf
Created February 29, 2016 07:35
Show Gist options
  • Select an option

  • Save pzzrudlf/cf119890ebf47892460c to your computer and use it in GitHub Desktop.

Select an option

Save pzzrudlf/cf119890ebf47892460c to your computer and use it in GitHub Desktop.
public function actionSignupForm()
{
$model = new SignupForm();
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($user = $model->signup()) {
if(Yii::$app->getUser()->login($user)) {
return $this->goHome();
}
}
return $this->render('signup', [
'model' => $model,
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment