I try to make custom login form in Yii2 Basic , without the ActiveForm widget . I made form which I want to use for login but , when I try to login it doesnt login only refresh the page , so maybe I miss something or I dont do it like it should be . I use email address instead of username , and with ActiveForm it all work but when I try to make it custom there is that issue .
This is my login form that I want to make custom :
<div class="login-message">
<h1><?= Html::encode($this->title) ?></h1>
</div>
<form method="post">
<div>
<span class=""> Email </span>
<input value="<?php $model->email ?>" placeholder="Write your email address" type="text">
</div>
<div>
<span class=""> Password </span>
<input value="<?php $model->password ?>" placeholder="Write your password" type="password">
</div>
<div class="form-group">
<div>
<div class="register">
<?= Html::a(Yii::t("app", "Register"), ["/site/register"]) ?>
</div>
<br>
<div class="forgot-pas">
<?= Html::a(Yii::t("app", "Forgotten password") . "?", ["/site/forgot"]) ?>
<br>
</div>
<br>
<div class="login-button">
<button class="btn btn-success" type="submit"> Login </button>
</div>
</div>
</div>
<input type="hidden" value="" name="_csrf" >
</form>
My action in SiteController for Login :
public function actionLogin() {
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
}
return $this->render('login', [
'model' => $model,
]);
}