Commit c5e9d84c by Alexander Makarov

signup action for advanced app template

parent 4879d83d
......@@ -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,
));
}
}
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/**
* @var yii\base\View $this
* @var yii\widgets\ActiveForm $form
* @var common\models\User $model
*/
$this->title = 'Signup';
$this->params['breadcrumbs'][] = $this->title;
?>
<h1><?php echo Html::encode($this->title); ?></h1>
<p>Please fill out the following fields to signup:</p>
<?php $form = ActiveForm::begin(array('options' => array('class' => 'form-horizontal'))); ?>
<?php echo $form->field($model, 'username')->textInput(); ?>
<?php echo $form->field($model, 'email')->checkbox(); ?>
<?php echo $form->field($model, 'password')->textInput(); ?>
<div class="form-actions">
<?php echo Html::submitButton('Signup', array('class' => 'btn btn-primary')); ?>
</div>
<?php ActiveForm::end(); ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment