Creating Drop Down Menu And Form In Thymeleaf
I want to create a drop down menu that allows a client to search users by a field specified in the drop down menu. For example, search by state, search by city, etc. This is what I
Solution 1:
Because the accepted answer is not using Thymeleaf and this question is top in Google I'm adding my solution here.
In my situation statues
is a list of Enum values. Model attribute is populated as usually you do in Spring:
mav.addObject("statuses", EnumSet.allOf(Status.class));
Group has a filed of type Status (the enum).
<div class="form-group row">
<select class="form-control" id="status" name="status">
<option th:each="stat : ${statuses}"
th:value="${stat}"
th:text="${stat}"
th:selected="${stat.equals(group.status)}"/>
</select>
</div>
This automatically populates the list and selects value that is selected in my Group instance:
Solution 2:
You have just the required answer in this link:
Post a Comment for "Creating Drop Down Menu And Form In Thymeleaf"