vendredi 21 mai 2021

Thymeleaf : Datalist autocomplete

 <div class="col-8 mb-1">

    <small class="form-text text-muted">Localité sinistre</small>

    <input class="form-control form-control-sm" list="listeLocalites" type="text" id="localite" th:field="*{localiteLieuSinistreDossier}"  placeholder="Localité lieu sinistre..."/>

    <datalist id="listeLocalites" name="localiteLieuSinistreDossier">

        <option th:if="${dossier.localiteLieuSinistreDossier}" th:each="ls:${listeLocalites}" th:value="${ls.codeLocalite}" th:label="${ls.codePostal.codePostal + ' ' + ls.libelleLocalite + ' ' + ls.delegation.libelleDelegation + ' ' + ls.delegation.gouvernorat.libelleGouvernorat}" th:selected="${dossier.localiteLieuSinistreDossier.codeLocalite==ls.codeLocalite}"></option>

        <option th:under="${dossier.localiteLieuSinistreDossier}" th:each="ls:${listeLocalites}" th:value="${ls.codeLocalite}" th:label="${ls.codePostal.codePostal + ' ' + ls.libelleLocalite + ' ' + ls.delegation.libelleDelegation + ' ' + ls.delegation.gouvernorat.libelleGouvernorat}"></option>

    </datalist>

</div>


Aucun commentaire:

Enregistrer un commentaire