<?php
/** @var yii\web\View $this */
/** @var app\models\LoginForm $model */

use yii\helpers\Html;
use yii\widgets\ActiveForm;

$this->title = 'Login';
?>

<?php if (Yii::$app->session->hasFlash('error')): ?>
    <div class="lms-alert lms-alert-danger" data-auto-dismiss>
        <i class="fas fa-exclamation-circle"></i>
        <?= Html::encode(Yii::$app->session->getFlash('error')) ?>
    </div>
<?php endif; ?>

<?php $form = ActiveForm::begin([
    'id'          => 'login-form',
    'options'     => ['autocomplete' => 'off'],
    'enableAjaxValidation'   => false,
    'enableClientValidation' => true,
    'validateOnBlur'         => false,
    'validateOnType'         => false,
    'fieldConfig'            => [
        'errorOptions' => ['class' => 'field-error'],
        'options'      => ['class' => 'lms-form-group'],
    ],
]); ?>

<!-- Username -->
<div class="lms-form-group">
    <label class="lms-label">
        <i class="fas fa-user"></i> Username
    </label>
    <div class="lms-input-wrap">
        <?= $form->field($model, 'username', [
                'options'  => ['tag' => false],
                'template' => '{input}{error}',
            ])
            ->textInput([
                'class'        => 'lms-input',
                'placeholder'  => 'Enter your username',
                'autocomplete' => 'off',
                'autofocus'    => true,
            ])
        ?>
    </div>
</div>

<!-- Password -->
<div class="lms-form-group">
    <label class="lms-label">
        <i class="fas fa-lock"></i> Password
    </label>
    <div class="lms-input-wrap lms-input-with-icon">
        <?= $form->field($model, 'password', [
                'options'  => ['tag' => false],
                'template' => '{input}{error}',
            ])
            ->passwordInput([
                'id'           => 'login-pwd',
                'class'        => 'lms-input',
                'placeholder'  => 'Enter your password',
                'autocomplete' => 'off',
            ])
        ?>
        <button type="button" class="toggle-password" data-target="login-pwd" tabindex="-1">
            <i class="fas fa-eye"></i>
        </button>
    </div>
</div>

<!-- Remember me -->
<div class="lms-form-row-check">
    <?= $form->field($model, 'rememberMe', [
            'options'  => ['tag' => false],
            'template' => '{input}{label}',
        ])
        ->checkbox(['class' => 'lms-check-input'])
        ->label('Keep me signed in', ['class' => 'lms-check-label'])
    ?>
</div>

<!-- Submit -->
<?= Html::submitButton(
    '<i class="fas fa-sign-in-alt"></i> Sign In',
    ['class' => 'lms-btn-submit', 'id' => 'btn-login']
) ?>

<?php ActiveForm::end(); ?>
