Does anyone know how to add a default setting of checked
in a Thymeleaf, SpringBoot, Java project, to an input field for a Single checkbox?
I have to use th:field
because I am later submitting this form via email and if I use th:name
with the checked box default, the default works but email doesn't.
Any suggestions?
<label>
<input type="checkbox" id="serviceLevel" th:field="*{serviceLevel}" th:checked="${serviceLevel}"/>
Affiliate Serviced</label>
Email html code to pull value on email:
<tr class="emailRow">
<h3>Direct: </h3>
<td class="bodycopy" th:text="${directBind.directBox}">
</td>
</tr>
I have this variable set as private Boolean directBox in the model.
I've tried everything: th:checked=checked
, value=true
, value=checked
, set the value and checked ="${directBox}"
none of this works.
Is there a solution out there?