diff --git a/apps/advanced/frontend/controllers/SiteController.php b/apps/advanced/frontend/controllers/SiteController.php index 85304d6..7fce71c 100644 --- a/apps/advanced/frontend/controllers/SiteController.php +++ b/apps/advanced/frontend/controllers/SiteController.php @@ -6,6 +6,7 @@ use Yii; use yii\web\Controller; use common\models\LoginForm; use frontend\models\ContactForm; +use common\models\User; class SiteController extends Controller { @@ -58,4 +59,19 @@ class SiteController extends Controller { return $this->render('about'); } + + public function actionSignup() + { + $model = new User(); + $model->setScenario('signup'); + if ($model->load($_POST) && $model->save()) { + if (Yii::$app->getUser()->login($model)) { + $this->redirect('index'); + } + } + + return $this->render('signup', array( + 'model' => $model, + )); + } } diff --git a/apps/advanced/frontend/views/site/signup.php b/apps/advanced/frontend/views/site/signup.php new file mode 100644 index 0000000..0047e51 --- /dev/null +++ b/apps/advanced/frontend/views/site/signup.php @@ -0,0 +1,24 @@ +title = 'Signup'; +$this->params['breadcrumbs'][] = $this->title; +?> +

title); ?>

+ +

Please fill out the following fields to signup:

+ + array('class' => 'form-horizontal'))); ?> + field($model, 'username')->textInput(); ?> + field($model, 'email')->checkbox(); ?> + field($model, 'password')->textInput(); ?> +
+ 'btn btn-primary')); ?> +
+