to Integrate select2 in a Livewire: check these articles
https://medium.com/@m.gaddour1981/use-of-livewire-and-select2-in-laravel-9-2ef46b8e9c97 https://startutorial.com/view/using-select2-with-laravel-livewire
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
@if($account_type == 'debit')
<div class="subaccountsfileds" >
<div class="form-group col-span-6 sm:col-span-4" wire:ignore>
<label for="exampleFormControlInput4" class=""> Account </label>
<select class=" newdata form-control" name="subaccount" wire:model="subaccount" id="newsubaccount">
<option value="">Select Account</option>
<optgroup label="Income">
@foreach($income as $account)
<option value="{{$account['id']}}">{{ucfirst(str_replace('-',' ',$account['name']))}}</option>
@endforeach
</optgroup>
<optgroup label="Expense">
@foreach($expense as $account)
<option value="{{$account['id']}}">{{ucfirst(str_replace('-',' ',$account['name']))}}</option>
@endforeach
</optgroup>
<optgroup label="Profit Expense">
@foreach($profit as $account)
<option value="{{$account['id']}}">{{ucfirst(str_replace('-',' ',$account['name']))}}</option>
@endforeach
</optgroup>
</select>
</div>
</div>
@endif
This is my code, and when the condition satisfies div is shown, but after that I am not able to add select2 to the newsubaccount id
Please help, thanks
Please or to participate in this conversation.