Given the following POJO which only has two fields:
Entity:
- id
- name
I have a form with the following select:
<select required="required" name="name" id="myId">
<option th:disabled="disabled" selected="true" value="">Choose Value</option>
<option th:each="element : ${elements}"
th:value="${element.id}"
th:text="${element.name}">
</option>
</select>
I'm trying to populate the entity fields so the id field is populated through the th:value (which would be the value of the selected element.id) and the name field is populated through the th:text (which would be the value of the selected element.name).
As I understand (and what I achieved) is that I only can populate one field using html select tag (the one I set in name's select tag). Any idea about how can I get both th:text and th:value values mapped in my entity using thymeleaf?