fastadmin 给下拉框赋值

时间:2021-08-19

fastadmin 给下拉框赋值

<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Booking')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select  id="c-booking" class="form-control selectpicker" name="row[booking]">
                {foreach name="bookingList" item="vo"}
                <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
                {/foreach}
            </select>
        </div>
</div>

js中

add: function () {
    let that = this;
    $("#c-product_id").data("eSelect", function(e){
        $('#c-booking').selectpicker('val', e.booking);
        $('#c-booking').selectpicker('refresh');
    });
    Controller.api.bindevent();
}