Есть форма:
<div data-role="page" id="login">
<div data-role="header">
<h2>Авторизация</h2>
</div>
<div role="main" class="ui-content jqm-content">
<form role="form" action="/site/login" method="POST" id="login-form">
<div class="ui-grid-solo">
<div class="ui-grid-a">
<label for="username">Имя</label>
<input type="text" name="username" id="username" value="" data-clear-btn="true" data-mini="true">
<label for="password">Пароль</label>
<input type="password" name="password" id="password" value="" data-clear-btn="true" autocomplete="off" data-mini="true">
<input type="checkbox" name="remind" id="remind" value="1">
<label for="remind">Запомнить меня</label>
<br>
<input type="submit" value="Логин" onclick="this.form.submit();">
</div>
</div>
</form>
</div>
</div>
В SiteController перенаправляю на форму:
public function actionIndex()
{
if (\Yii::$app->user->isGuest) {
return $this->render('login');
}
else {
return $this->goBack();
}
}
В этом же SiteController идёт обработка actionLogin:
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return $this->render('index');
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->render('about');
} else {
return $this->render('contact');
}
}
В LoginForm:
public function rules()
{
return [
[['username', 'password'], 'required'],
['remind', 'boolean'],
['password', 'validatePassword'],
];
}
public function login()
{
if ($this->validate()) {
return Yii::$app->user->login($this->getUser(), $this->remind ? 3600 * 24 * 30 : 0);
} else {
return false;
}
}
При отправке POST-сообщения возникает ошибка:
Bad Request (#400)
Unable to verify your data submission.
The above error occurred while the Web server was processing your request.
Please contact us if you think this is a server error. Thank you.
В чём дело?