vendredi 11 mai 2018

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 Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2I7tz1J
via IFTTT

Aucun commentaire:

Enregistrer un commentaire