fastadmin 下拉框(多选)

1 mysql

 

2 js

{field: 'flag', title: __('Flag'), searchList: {"hot":__('Flag hot'),"index":__('Flag index'),"recommend":__('Flag recommend')}, operate:'FIND_IN_SET', formatter: Table.api.formatter.label}

3 add.html

<div class="form-group">
    <label class="control-label col-xs-12 col-sm-2">{:__('Flag')}:</label>
    <div class="col-xs-12 col-sm-8">
        <select  id="c-flag" data-rule="required" class="form-control selectpicker" multiple="" name="row[flag][]">
            {foreach name="flagList" item="vo"}
                <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
            {/foreach}
        </select>
    </div>
</div>

4 edit.html

<div class="form-group">
    <label class="control-label col-xs-12 col-sm-2">{:__('Flag')}:</label>
    <div class="col-xs-12 col-sm-8">
        <select  id="c-flag" data-rule="required" class="form-control selectpicker" multiple="" name="row[flag][]">
            {foreach name="flagList" item="vo"}
                <option value="{$key}" {in name="key" value="$row.flag"}selected{/in}>{$vo}</option>
            {/foreach}
        </select>
    </div>
</div>

5 controller

public function _initialize()
{
    parent::_initialize();
    $this->view->assign("flagList", $this->model->getFlagList());
}

6 model

public function getFlagList()
{
    return ['hot' => __('Flag hot'), 'index' => __('Flag index'), 'recommend' => __('Flag recommend')];
}
posted @ 2020-07-13 14:53  CanyingV  阅读(4593)  评论(0编辑  收藏  举报