thymeleaf-docs
thymeleaf-docs copied to clipboard
Improvement in Thymeleaf checkbox Documentation for feeding toggled value back to controller back-end
I had recently faced the problem while using th:checked
attribute as described in thymeleaf checkbox section.
Since th:checked
attribute is single valued, its value does not change as checkbox is ticked or unticked. Hence, it cannot be used as user input to submit data from front-end to back-end.
It took me 2 days to find the workaround, but i was able to change checkbox value and get it as input at backend.
For that, i used th:field
attribute rather than th:checked
attribute in checkbox.
The detailed answer is provided on this stackoverflow link: https://stackoverflow.com/a/72300493/15730570
If possible, kindly add the details about how checkbox can be used to toggle boolean value and feed it back to controller in thymelaef documentation for future reference.
Thank you.
Moving to the thymeleaf-docs project since it makes more sense to solve there if we do
@ultraq acknowledged. Thank you.