我想要实现的是,有两个模型 A 和 B 具有一对多的关系,其中 A 有许多 B。因此,如果 A 和 B 的记录已经创建,则 A 可以分配给许多 B。所以我用livewire开始了当前的项目,现在我不知所措。具有多个的正常选择效果很好,并填充 Livewire 后端的数组。但是当我使用 select2 时,数组中没有存储任何内容,当我添加它时,它显示一个空数组。尽管 livewire 提供了一组很棒的工具,但我开始意识到存在很多灰色区域,其中缺少或缺乏外部支持,例如这里的 select2。
这是我到目前为止所做的:
<div>
<div class="tab-pane fade show active" id="card1" role="tabpanel" aria-labelledby="card1-tab">
<div class="pt-3"></div>
<div class="row" >
<div class="form-group col">
<label for="cards">Enter Cards</label>
<select class="form-control select2" id="cards" multiple="multiple" onchange="this.dispatchEvent(new InputEvent('input'))>
<option disabled="">Select Cards</option>
@foreach($cardsUnassigned as $card)
<option value="{{ $card->id }}">{{ $card->imei_number }}</option>
@endforeach
</select>
</div>
<div class="form-group col">
<label for="technicians" class="">Technicians</label>
<select class="form-control select2" id="technicians" wire:model='techies.'>
<option disabled="">Select Technicians</option>
@foreach($technicians …Run Code Online (Sandbox Code Playgroud)