Reputation: 1019
Is there a way to tell Thymeleaf that if any of the fields have errors, display the error message?
I'm currently listing them out individually like this:
<div th:if="${#fields.hasErrors('password')}" th:errors="*{password}" class="validation-message alert alert-danger" role="alert"></div>
<div th:if="${#fields.hasErrors('lastName')}" th:errors="*{lastName}" class="validation-message alert alert-danger" role="alert"></div>
<div th:if="${#fields.hasErrors('firstName')}" th:errors="*{firstName}" class="validation-message alert alert-danger" role="alert"></div>
Upvotes: 0
Views: 264
Reputation: 20487
http://www.thymeleaf.org/doc/tutorials/3.0/thymeleafspring.html#all-errors
Should be able to do something like:
<div th:each="err : ${#fields.errors('*')}" class="validation-message alert alert-danger" role="alert" th:text="${err}" />
Upvotes: 3