<!DOCTYPE html>
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{default}">

<head>
    <title>Панель администратора (пользователи)</title>
</head>

<body th:with="bodyClass='bg-white', mainClass='my-0'">
    <main layout:fragment="content">
        <form class="col-lg-8 col-xl-7 col-xxl-6" action="#" th:action="@{/admin/user/edit/{id}(id=${user.id}, page=${page})}"
            th:object="${user}" method="post">
            <div class="mb-4">
                <label for="id" class="form-label">ID</label>
                <input type="text" th:value="*{id}" id="id" class="form-control" readonly disabled>
            </div>
            <div class="mb-4">
                <label for="login" class="form-label">Имя пользователя (логин)</label>
                <input type="text" th:field="*{login}" id="login" class="form-control">
                <div th:if="${#fields.hasErrors('login')}" th:errors="*{login}" class="invalid-feedback"></div>
            </div>
            <div class="mb-4">
                <label for="password" class="form-label">Пароль</label>
                <input type="password" id="password" th:field="*{password}" class="form-control">
                <div th:if="${#fields.hasErrors('password')}" th:errors="*{password}" class="invalid-feedback"></div>
            </div>
            <div class="mb-4">
                <label for="firstname" class="form-label">Имя</label>
                <input type="text" th:field="*{firstname}" id="firstname" class="form-control">
                <div th:if="${#fields.hasErrors('firstname')}" th:errors="*{firstname}" class="invalid-feedback">
                </div>
            </div>
            <div class="mb-4">
                <label for="lastname" class="form-label">Фамилия</label>
                <input type="text" th:field="*{lastname}" id="lastname" class="form-control">
                <div th:if="${#fields.hasErrors('lastname')}" th:errors="*{lastname}" class="invalid-feedback">
                </div>
            </div>
            <div class="mb-4">
                <label for="email" class="form-label">Почта</label>
                <input type="email" th:field="*{email}" id="email" class="form-control">
                <div th:if="${#fields.hasErrors('email')}" th:errors="*{email}" class="invalid-feedback">
                </div>
            </div>
            <div class="d-flex flex-column align-items-center mb-5">
                <button class="btn btn-primary w-50 rounded-5 edit-btn" type="submit" id="add-btn">Сохранить пользователя</button>
                <a class="btn btn-secondary w-25 mt-4 edit-btn"
                    th:href="@{/admin/user(page=${page})}">Отмена</a>
            </div>
        </form>
        </div>
    </main>
</body>

</html>