I want to keep the values in multiselect however, it shows Undefined offset: 2. The codes is below for the blade file.
<select multiple="multiple" name="warehouseId[]" id="warehouse" class="form-control" style="width:100%;">
@if($warehouseData)
@foreach ($warehouseData as $key => $warehouse)
<option value="{{$warehouse->id}}" >{{$warehouse->name}} {{$adminUserWarehouseSelectedData[$key]->id}}</option>
@endforeach
@endif
</select>
I think the answer you have accepted here is not 100% right. You have multiple data in
$adminUserWarehouseSelectedData
coming from controllers. As you have used multiple select here I assumed that.So this is the proper way to do it.
Add an
@isset
directive