thymeleaf-docs icon indicating copy to clipboard operation
thymeleaf-docs copied to clipboard

Improvement in Thymeleaf checkbox Documentation for feeding toggled value back to controller back-end

Open muhammadismailkhan0009 opened this issue 2 years ago • 2 comments

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.

muhammadismailkhan0009 avatar May 19 '22 10:05 muhammadismailkhan0009

Moving to the thymeleaf-docs project since it makes more sense to solve there if we do

ultraq avatar May 20 '22 06:05 ultraq

@ultraq acknowledged. Thank you.

muhammadismailkhan0009 avatar May 20 '22 06:05 muhammadismailkhan0009