an option can be just an object instead of a list of objects?
in the documentation each sweeps a list but I would like to retrieve a single object
<select th:field="*{type}">
<option th:each="type : ${allTypes}"
th:value="${type}"
th:text="#{${'seedstarter.type.' + type}}">Wireframe</option>
</select>
is possible do somethint like
<option th:each="${Types}"
The Standard Dialect in thymeleaf offers Using th:each
. Its the Iteration basics.
“for each element in the result of evaluating ${allTypes}, repeat this fragment of template setting that element into a variable called type”.
Dropdown Selector usually is for a list of options to be displayed.
You simply cant do th:each="${Types}"
, as you need to declare a variable to access the iterated variable
https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#using-theach