Skip to content

Commit

Permalink
#270 Extract add employee fragment to separate template (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
conorheffron authored Oct 16, 2024
1 parent 94369b8 commit 9d4b48c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
28 changes: 28 additions & 0 deletions src/main/resources/templates/add-employee.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<div class="container">
<br />
<h3>Manage data entries below</h3>
<br />
<form action="#" th:action="@{/add}" th:object="${person}" method="post" class=".form-control">
<label for="title"></label>
<input type="text" th:field="*{title}" id="title" placeholder="Enter Title.....">
<br />
<span th:if="${#fields.hasErrors('title')}" th:errors="*{title}" class="error"></span>
<br />
<label for="firstName"></label>
<input type="text" th:field="*{firstName}" id="firstName" placeholder="Enter First Name.....">
<br />
<span th:if="${#fields.hasErrors('firstName')}" th:errors="*{firstName}" class="error"></span>
<br />
<label for="surname"></label>
<input type="text" th:field="*{surname}" id="surname" placeholder="Enter Surname.....">
<br />
<span th:if="${#fields.hasErrors('surname')}" th:errors="*{surname}" class="error"></span>
<br />
<label for="age"></label>
<input type="number" th:field="*{age}" id="age" placeholder="Enter Age.....">
<br />
<span th:if="${#fields.hasErrors('age')}" th:errors="*{age}" class="error"></span>
<br />
<input type="submit" value="Add Employee" class="btn btn-default">
</form>
</div>
29 changes: 1 addition & 28 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,7 @@

<header th:replace="~{navbar.html}"></header>

<div class="container">
<br />
<h3>Manage data entries below</h3>
<br />
<form action="#" th:action="@{/add}" th:object="${person}" method="post" class=".form-control">
<label for="title"></label>
<input type="text" th:field="*{title}" id="title" placeholder="Enter Title.....">
<br />
<span th:if="${#fields.hasErrors('title')}" th:errors="*{title}" class="error"></span>
<br />
<label for="firstName"></label>
<input type="text" th:field="*{firstName}" id="firstName" placeholder="Enter First Name.....">
<br />
<span th:if="${#fields.hasErrors('firstName')}" th:errors="*{firstName}" class="error"></span>
<br />
<label for="surname"></label>
<input type="text" th:field="*{surname}" id="surname" placeholder="Enter Surname.....">
<br />
<span th:if="${#fields.hasErrors('surname')}" th:errors="*{surname}" class="error"></span>
<br />
<label for="age"></label>
<input type="number" th:field="*{age}" id="age" placeholder="Enter Age.....">
<br />
<span th:if="${#fields.hasErrors('age')}" th:errors="*{age}" class="error"></span>
<br />
<input type="submit" value="Add Employee" class="btn btn-default">
</form>
</div>
<header th:replace="~{add-employee.html}"></header>

<header th:replace="~{employee-list.html}"></header>

Expand Down

0 comments on commit 9d4b48c

Please sign in to comment.