<!DOCTYPE html>
<html lang="en"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div layout:fragment="content">
    <div th:text="${errors}" class="margin-bottom alert-danger"></div>
    <form action="#" th:action="@{/user/{id}(id=${id})}" th:object="${userDto}" method="post">
        <div class="mb-3">
            <label for="firstName" class="form-label">Имя</label>
            <input type="text" class="form-control" id="firstName" th:field="${userDto.firstName}" required="true">
        </div>
        <div class="mb-3">
            <label for="lastName" class="form-label">Фамилия</label>
            <input type="text" class="form-control" id="lastName" th:field="${userDto.lastName}" required="true">
        </div>
        <div class="mb-3">
            <label for="email" class="form-label">Почта</label>
            <input type="text" class="form-control" id="email" th:field="${userDto.email}" required="true">
        </div>
        <div class="mb-3">
            <button type="submit" class="btn btn-primary button-fixed">
                <span th:if="${id == null}">Добавить</span>
                <span th:if="${id != null}">Обновить</span>
            </button>
            <a class="btn btn-secondary button-fixed" th:href="@{/user}">
                Назад
            </a>
        </div>
    </form>
</div>
</body>
</html>