Newer
Older
teacher-diary / src / main / resources / templates / student / form.html
<!DOCTYPE html>
<html lang="ru" xmlns:th="http://www.thymeleaf.org"
      th:replace="~{layout/main :: html(pageTitle=${pageTitle}, activeMenu='students', content=~{::content}, scripts=~{})}">
<body>
<th:block th:fragment="content">
    <div class="card">
        <div class="card-body">
            <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>

            <form th:action="${request.id != null} ? @{/students/{id}/edit(id=${request.id})} : @{/students/new}"
                  method="post" th:object="${request}">

                <div class="row">
                    <div class="col-md-4 mb-3">
                        <label for="lastName" class="form-label">Фамилия <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" id="lastName" th:field="*{lastName}"
                               th:classappend="${#fields.hasErrors('lastName')} ? 'is-invalid'" required>
                        <div class="invalid-feedback" th:if="${#fields.hasErrors('lastName')}" th:errors="*{lastName}"></div>
                    </div>
                    <div class="col-md-4 mb-3">
                        <label for="firstName" class="form-label">Имя <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" id="firstName" th:field="*{firstName}"
                               th:classappend="${#fields.hasErrors('firstName')} ? 'is-invalid'" required>
                        <div class="invalid-feedback" th:if="${#fields.hasErrors('firstName')}" th:errors="*{firstName}"></div>
                    </div>
                    <div class="col-md-4 mb-3">
                        <label for="patronymic" class="form-label">Отчество</label>
                        <input type="text" class="form-control" id="patronymic" th:field="*{patronymic}">
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label for="phone" class="form-label">Телефон</label>
                        <input type="tel" class="form-control" id="phone" th:field="*{phone}" placeholder="+7 (999) 123-45-67">
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="birthDate" class="form-label">Дата рождения</label>
                        <input type="date" class="form-control" id="birthDate" th:field="*{birthDate}">
                    </div>
                </div>

                <div class="mb-3">
                    <label for="notes" class="form-label">Заметки</label>
                    <textarea class="form-control" id="notes" th:field="*{notes}" rows="3" placeholder="Дополнительная информация об ученике..."></textarea>
                </div>

                <div class="d-flex gap-2">
                    <button type="submit" class="btn btn-primary">
                        <i class="bi bi-check-lg me-1"></i> Сохранить
                    </button>
                    <a th:href="${request.id != null} ? @{/students/{id}(id=${request.id})} : @{/students}" class="btn btn-outline-secondary">
                        Отмена
                    </a>
                </div>
            </form>
        </div>
    </div>
</th:block>
</body>
</html>