When searching, if we select a given field to search within and submit, our choice is forgotten. How could someone modify the view template to keep the previous search field selected when displaying results?
I have read many other SO questions and the thymeleaf documentation here but have not found a suitable answer yet.
One can hard code a string (like employer) with the following:
search.html snippet
<span th:each="column : ${columns}">
<input
type="radio"
name="searchType"
th:id="${column.key}"
th:value="${column.key}"
th:checked="${column.key == 'employer'}"/>
<label th:for="${column.key}" th:text="${column.value}"></label>
</span>
SearchController.html snippet
@RequestMapping(value = "")
public String search(Model model) {
model.addAttribute("columns", columnChoices);
return "search";
}
How can I persist the user selected radio value upon POST in Thymeleaf Spring? (and default to the first, value on the GET)