复选框遍历与

<div class="layui-form-item">
<label class="layui-form-label">图库</label>
<div class="layui-input-block">
<tr th:each="d : ${data}">
<input type="checkbox" th:value="${d.id}" name="imageSource" th:title="${d.name}" th:attr="checked=${d.checked }" />
</tr>
</div>
</div>
- data 为后端返回的数据是一个List对象。
- 这些属性都必须有,不然会报错,例如 d.checked 是必须有 checked 这个属性。
判断选中

<div class="layui-form-item">
<label class="layui-form-label">状态</label>
<div class="radio-box">
<input type="radio" id="radio-1" value="0" name="status" th:attr="checked=${status == 0}">
<label for="radio-1">有效</label>
<input type="radio" id="radio-2" value="1" name="status" th:attr="checked=${status == 1}">
<label for="radio-2">无效</label>
</div>
</div>
- 同样的问题是status也是必须要有的