Browse Source

signup action for advanced app template

tags/2.0.0-alpha
Alexander Makarov 11 years ago
parent
commit
c5e9d84c6a
  1. 16
      apps/advanced/frontend/controllers/SiteController.php
  2. 24
      apps/advanced/frontend/views/site/signup.php

16
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,
));
}
}

24
apps/advanced/frontend/views/site/signup.php

@ -0,0 +1,24 @@
<?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(); ?>
Loading…
Cancel
Save