can't use disabled selected with Thyemeleaf th:field

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

can't use disabled selected with Thyemeleaf th:field

fateh
I have Select option and I want to use disable selected for the first option but when I use th:field its override it and enable the first option. So I tried to use th:id ,th:name, th:value as this question suggested but what happened is the select option start to pickup the last value from the list and ignore the value coming from the model attribute here the code portion
<div class="md-form">
<select name="coordinate" id="coordinate" th:field="*{coordinateSystem}">
    <option value="" disabled selected><label>Choose Coordinate</label></option>
    <option th:each="coordinate : ${data.coordinateSystemList}"
            th:value="${coordinate}"
            th:selected="${data.coordinateSystem}"
            th:text="${coordinate}">
    </option>
</select>
<label class="active" for="coordinate">Coordinate</label>