Greetings!
Thymeleaf gives us almost everything we need. But there are some cases that thymeleaf does not work properly.
When we have a hidden field and we want to assign it a value, strangely thymeleaf will ignore the value property.
Solution:
Use th:attr
Thymeleaf gives us almost everything we need. But there are some cases that thymeleaf does not work properly.
When we have a hidden field and we want to assign it a value, strangely thymeleaf will ignore the value property.
Solution:
Use th:attr
th:attr="name='
<tr th:each="user, stat : ${users}"> <input type="hidden" th:attr="name='userDtos[' + ${stat.index} + '].userId'" th:value="${user.id}" /> <!--some other inputs--> <td> <input type="checkbox" th:field="*{userDtos[__${stat.index}__].active}" /> </td></tr>
I just had this problem, this worked for me. Thank you Manju!
ReplyDeleteI can't believe this works and th:field doesn't!
tnks manju
ReplyDeleteTwo days searching for a solution.
ReplyDeleteThank you Manju! Thank you really much.
Awesome , thanks buddy
ReplyDelete