2016-02-26 33 views
1

我正在使用物化大规模选择表格http://materializecss.com/forms.html#select它需要正确的行为第一选项被禁用和选择。 百里香忽略禁用选项,尽管它被选中。相反,它会选择第一个未禁用的选项。百里香不会选择禁用选项

<div class="input-field col s6"> 
    <select th:field="*{locale}" th:errorclass="invalid"> 
     <option value="" selected="selected" disabled="disabled">Choose your option</option> 
     <option value="cs">Czech</option> 
     <option value="en">English</option> 
    </select> 
    <label>Locale</label> 
</div> 

捷克自动选择,但我想看看选择你的选项要代为选择。

+2

尝试使用'日:selected'和'日:disabled'代替。如果你尝试,按照[这个](http://forum.thymeleaf.org/th-selected-not-working-on-multiple-select-td4025883.html)替换'name'属性的'th:field' – Enigo

回答

2

基于Enigo评论。我已经使它与这些变化一起工作。

<select name="locale" id="locale" th:errorclass="invalid" required="required" > <option value="" th:disabled="disabled" th:selected="selected">Choose your option</option> <option value="cs">Czech</option> <option value="en">English</option> </select>

0

日:字段个:选择同时不工作。 对于此删除th:字段并将其替换为id名称属性manualy。

检查论坛thymeleaf-forum

我有同样的问题。

我分享我的代码。

<div class="row"> 
<div class="input-field col s12"> 
    <select id="doc" name="doc" th:with="doc=*{doc}"> 
        <option value="" th:disabled="disabled" selected="true" 
         th:text="${status==true}? 'Seleccione tipo de documento' : ${doc}">Seleccione 
         tipo de documento</option> 
        <option th:each="tipoDoc : ${tipoDocs}" th:text="${tipoDoc}" 
         th:value="${tipoDoc}" /> 
       </select> 
    <label>Documento</label> 
</div> 

Salu2