Answer the question
In order to leave comments, you need to log in
Why is Yii2 authorization not working?
Version Yii2 basic 2.0.9. Standard authorization via LoginForm works. It is necessary to add the possibility of authorization through a modal window located in layouts/main.php. Next form:
<div class="modal fade" id="enter" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="site-login">
<?php $form = ActiveForm::begin(['id' => 'login-form',]); ?>
<div class="modal__dialog" role="document">
<div class="modal__content">
<div class="modal__header">
<button type="button" class="modal__close" data-dismiss="modal" aria-label="Close">
<img src="images/modal-close.png" alt="">
</button>
<h4 class="modal__title">Войти на сайт</h4>
</div>
<div class="modal__body">
<div class="enter-form">
<form action="LoginForm">
<div class="modal__input">
<div class="modal__label">
Ваш логин:*
</div>
<div class="modal__input-block">
<input type="text" name="LoginForm[username]" class="input__item">
<a href="#" class="ques-icon">
<img src="images/ques-icon.png" alt="">
</a>
</div>
</div>
<div class="modal__input">
<div class="modal__label">
Пароль:*
</div>
<div class="modal__input-block">
<input type="password" name="LoginForm[password]" class="input__item input__item_password">
<a href="#" class="forget-link">Забыли пароль?</a>
</div>
</div>
<div class="submit__input">
<?= Html::submitButton('Войти', ['class' => 'input__item', 'name' => 'login-button']) ?>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
_csrf 'azZHQ0thSTFYcyw7E1IIATwEKRs7JD1QGHoNBw4uOXo8BgwkJA0AeA=='
LoginForm [
'username' => 'test'
'password' => 'test'
]
login-button ''
<input type="text" name="LoginForm[username]" class="input__item">
<?= $form->field($model, 'username')->textInput(['autofocus' => true]) ?>
PHP Fatal Error - yii\base\ErrorException
Call to a member function formName() on null
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question