Livewire Select field selected

  laravel, laravel-livewire

I have a select field with values from a table that I would like to compare with another table and mark as selected if a value matches.

<select name="tour" class="form-control form-control-sm" wire:model="selectTour">
  @foreach($touren as $tour)
   <option {{ $beleg->Tour == $tour->Gruppe ? 'selected' : '' }} value="{{ $tour->Gruppe }}">{{ $tour->Gruppe }}</option>

If I now reload the page, the matching value is briefly marked as selected, but automatically jumps back to “Please select”.

If I remove wire:model=“selectTour” it works. But can’t perform any actions with the select field.

Can anyone Help?

Source: Laravel

Leave a Reply