【发布时间】:2021-07-25 14:49:37
【问题描述】:
数据正在从数据库中获取,我想默认选择来自数据库的所有位置
@php
$default_location = null;
if(count($business_locations) == 1){
$default_location = array_key_first($business_locations->toArray());
}
@endphp
<div class="col-sm-4">
<div class="form-group">
{!! Form::label('product_locations', __('business.business_locations') . ':') !!} @show_tooltip(__('lang_v1.product_location_help'))
{!! Form::select('product_locations[]', $business_locations, $default_location, ['class' => 'form-control select2', 'multiple', 'id' => 'product_locations']); !!}
</div>
</div>
【问题讨论】:
-
{!! Form::select('product_locations[]', $business_locations, $default_location, ['class' => 'form-control select2', 'multiple', 'id' => 'product_locations'], 'selected' => 'true'); !!}我认为它可以满足您的需求。