Skip to content

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

Open
@muhammadismailkhan0009

Description

@muhammadismailkhan0009

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions