Laravel 5 Undefined offset: 1
In my laravel blade file, I have a multiselect box and the values are coming from the database / controller. Below are the values:
[{“id”:1,”name”:”United States”},{“id”:2,”name”:”United
Kingdom”},{“id”:3,”name”:”China”}]
I wanted to show the values in the multiselect box as well as the already selected values by the user (that’s are coming from the controller in another variable), see below;
[{“id”:2,”name”:”United Kingdom”}]
Below is the code for the multi select box:
<select multiple="multiple" name="warehouseId[]" id="warehouse" class="form-control" style="width:100%;" required>
@if($warehouseData)
@foreach ($warehouseData as $key => $warehouse)
<option value="" @if($adminUserWarehouseSelectedData[$key]->name == $warehouse->name) Selected @endif></option>
@endforeach
@endif
</select>
But it ended up with an error –
Undefined offset: 1
from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-5-undefined-offset-1/
via Lzo Media
No comments:
Post a Comment