<!DOCTYPE html>
<html lang="ru" xmlns:th="http://www.thymeleaf.org"
th:replace="~{layout/main :: html(pageTitle=${pageTitle}, activeMenu='parents', 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} ? @{/parents/{id}/edit(id=${request.id})} : @{/parents/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="email" class="form-label">Email <span class="text-danger">*</span></label>
<input type="email" class="form-control" id="email" th:field="*{email}"
th:classappend="${#fields.hasErrors('email')} ? 'is-invalid'" required>
<div class="invalid-feedback" th:if="${#fields.hasErrors('email')}" th:errors="*{email}"></div>
<small class="text-muted">На этот email будет отправлено приглашение</small>
</div>
<div class="col-md-6 mb-3">
<label for="phone" class="form-label">Телефон <span class="text-danger">*</span></label>
<input type="tel" class="form-control" id="phone" th:field="*{phone}"
th:classappend="${#fields.hasErrors('phone')} ? 'is-invalid'"
placeholder="+7 (999) 123-45-67" required>
<div class="invalid-feedback" th:if="${#fields.hasErrors('phone')}" th:errors="*{phone}"></div>
</div>
</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} ? @{/parents/{id}(id=${request.id})} : @{/parents}" class="btn btn-outline-secondary">
Отмена
</a>
</div>
</form>
</div>
</div>
</th:block>
</body>
</html>