<!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="@{/post/user/{userId}(userId=${userId})}" th:object="${postDto}" method="post">
        <div class="mb-3">
            <label for="image" class="form-label">Картинка</label>
            <input type="file" class="form-control" id="image" th:field="${postDto.image}" required="true">
        </div>
        <div class="mb-3">
            <label for="heading" class="form-label">Заголовок</label>
            <input type="text" class="form-control" id="heading" th:field="${postDto.heading}" required="true">
        </div>
        <div class="mb-3">
            <label for="content" class="form-label">Содержание</label>
            <input type="text" class="form-control" id="content" th:field="${postDto.content}" required="true">
        </div>
        <div class="mb-3">
            <button type="submit" class="btn btn-primary button-fixed">
                <span th:if="${userId != null}">Добавить</span>
            </button>
            <a class="btn btn-secondary button-fixed" th:href="@{/post}">
                Назад
            </a>
        </div>
    </form>
</div>
</body>
</html>