summaryrefslogtreecommitdiff
path: root/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/contact/form.html
blob: 0229e0d8d85983813efc9d5fefa2baff2a49273d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <title>Contact Us</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>
    <h1>Contact Us</h1>

    <form th:action="@{/contact}" th:object="${contactForm}" method="post">
        <div>
            <label>Name</label>
            <input type="text" th:field="*{name}" placeholder="Your name" />
            <div th:if="${#fields.hasErrors('name')}" th:errors="*{name}"></div>
        </div>

        <div>
            <label>Email</label>
            <input type="email" th:field="*{email}" placeholder="Your email" />
            <div th:if="${#fields.hasErrors('email')}" th:errors="*{email}"></div>
        </div>

        <div>
            <label>Message</label>
            <textarea th:field="*{message}" placeholder="Your message"></textarea>
            <div th:if="${#fields.hasErrors('message')}" th:errors="*{message}"></div>
        </div>

        <button type="submit">Send</button>
    </form>

</body>

</html>