I try in thymeleaf 3 to add required when it's the first element. I have already attribute name.
<div th:each="role, iter : ${roles}" th:remove="tag">
<input type="checkbox" th:attr="name='roles[]'" th:attrappend="${iter.first ? 'required' : ''}" th:value="${role.id}" th:text="${role.name}">
</div>
I get this error
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as assignation sequence: "${iter.first ? 'required'}"