tp5 select回显

<select name="role_id" id="" class="form-control" required>
    {volist name="roleData" key="key" id="vo"}
        <option value="{$vo.id}" {php}if(isset($data['role_id'])){   {/php} {$data['role_id']==$vo['id'] ? 'selected' : ''}{php}}{/php}>{$vo['name']}</option>
    {/volist}
<select name="role_id" id="" class="form-control" required>
    {volist name="roleData" key="key" id="vo"}
        {eq name="vo['id']" value="$data.role_id"}
        <option value="{$vo['id']}" selected>{$vo['name']}</option>
        {else/}
        <option value="{$vo['id']}">{$vo['name']}</option>
        {/eq}

    {/volist}
</select>

 注意:

select()出来的结果才可以volist

posted on 2018-06-24 16:03  薇薇123456  阅读(199)  评论(0编辑  收藏  举报

导航