th:field is a Thymeleaf attribute that connects a form control to a property on the form’s model object. For checkbox collections, it supplies the field name and preserves checked state when the form is redisplayed after validation errors. section 2.1.3
Binding taco ingredients
A taco form can iterate through available wrap ingredients, assign each ingredient’s identifier with th:value, and bind every checkbox to the model’s ingredients property with th:field="*{ingredients}". Thymeleaf then renders controls such as name="ingredients" and value="FLTO". section 2.1.3
<h3>Designate your wrap:</h3>
<div th:each="ingredient : ${wrap}">
<input th:field="*{ingredients}" type="checkbox"
th:value="${ingredient.id}"/>
<span th:text="${ingredient.name}">INGREDIENT</span><br/>
</div>
Browse the complete checkbox pattern: iterate over model data, bind the ingredients collection, render each identifier, and display its label. section 2.1.3
