#ask how to use select2 in form edit laravel

#ask
blade

 <td class="table-report__action w-56">
                                <div class="flex justify-center items-center">
                                    <a class="flex items-center mr-3" href="javascript:;" data-toggle="modal"
                                        onclick="editForm()"   data-target="#header-footer-modal-preview-{{ $project->id }}">
                                        <i data-feather="check-square" class="w-4 h-4 mr-1"></i> Edit
                                    </a>
                                    <a class="flex items-center text-theme-6" href="javascript:;" data-toggle="modal"
                                        data-target="#delete-confirmation-modal-{{ $project->id }}">
                                        <i data-feather="trash-2" class="w-4 h-4 mr-1"></i> Delete
                                    </a>
                                </div>
                            </td>
@foreach ($projects as $project)
        <div id="header-footer-modal-preview-{{ $project->id }}" class="modal" tabindex="-2" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <!-- BEGIN: Modal Header -->
                    <div class="modal-header">
                        <h2 class="font-medium text-base mr-auto">Form Edit</h2>
                    </div> <!-- END: Modal Header -->

                    <!-- BEGIN: Form -->
                    <form enctype="multipart/form-data" action="{{ $ACTION }}/save-edit/{{ $project->id }}"
                        method="POST">
                        @csrf
                        <!-- BEGIN: Modal Body -->
                        <div class="modal-body grid grid-cols-12 gap-4 gap-y-3">
                            <div class="col-span-12"> <label for="modal-form-6" class="form-label">User</label>
                                <select id="Edituser_id" data-id="{{ $project->id }}" class=" form-select" name="Edituser_id" required>
                                    <option disabled selected >-- Pilih User --</option>
                                    @foreach ($users as $user)
                                            <option value="{{ $user->id }}"
                                            {{ $user->id == $project->user_new_id ? 'selected' : '' }}>
                                            {{ $user->name }}</option>
                                    @endforeach
                                </select>
                                @if ($errors->has('user_id'))
                                    <span class="sm:ml-auto mt-1 sm:mt-0 text-xs text-gray-600">Required, please select
                                        user!</span>
                                @endif
                            </div>

                            <div class="col-span-12"> <label for="modal-form-6" class="form-label">Project
                                    Manager</label>
                                <select id="Editproject_manager_id" class="form-select" name="Editproject_manager_id" required>
                                    <option disabled selected >-- Pilih Project Manager --</option>
                                    @foreach ($projectManagers as $projectManager)
                                        <option value="{{ $projectManager->id }}"
                                            {{ $projectManager->id == $project->project_manager_id ? 'selected' : '' }}>
                                            {{ $projectManager->name }}</option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="col-span-12"> <label for="modal-form-1" class="form-label">Nama
                                    Project</label>
                                <input name="name" id="modal-form-1" type="text" class="form-control"
                                    placeholder="inputkan nama project" minlength="2" required
                                    value="{{ $project->name }}">
                            </div>

                            <div class="col-span-12"> <label for="modal-form-6" class="form-label">Bohir</label>
                                <select id="Editbohir_id" class=" form-select" name="Editbohir_id" >
                                    <option disabled selected >-- Pilih Bohir --</option>
                                    @foreach ($bohirs as $bohir)
                                        <option value="{{ $bohir->id }}" {{ $bohir->id == $project->bohir_id ? 'selected' : '' }}>
                                            {{ $bohir->name }}</option>
                                    @endforeach
                                </select>
                            </div>

                            {{-- <div class="col-span-12"> <label for="modal-form-6" class="form-label">Bohir</label>
                                <select id="bohir_id" class="searchBohir form-select" name="bohir_id" required>
                                    <option disabled selected >-- Pilih Bohir --</option>
                                    @foreach ($bohirs as $bohir)
                                        <option value="{{ $bohir->id }}"
                                            {{ $bohir->id == $project->bohir_id ? 'selected' : '' }}>
                                            {{ $bohir->name }}</option>
                                    @endforeach
                                </select>
                            </div> --}}

                            <div class="col-span-12"> <label for="modal-form-1" class="form-label">Tahun Anggaran</label>
                                <input name="nilai_anggaran" id="modal-form-1" type="number" class="form-control"
                                    placeholder="inputkan Nilai Anggran" minlength="2" required
                                    value="{{ $project->nilai_anggaran }}">
                            </div>

                            <div class="col-span-12"> <label for="modal-form-1" class="form-label">Tahun
                                    Anggaran</label>
                                <input name="fiscal_year" id="modal-form-1" type="number" class="form-control"
                                    placeholder="inputkan Tahun Anggaran" minlength="2" required
                                    value="{{ $project->fiscal_year }}">
                            </div>

                            <div class="col-span-12"> <label for="modal-form-1" class="form-label">Tanggal
                                    Kontrak</label>
                                <div class="relative">
                                
                                        <input type="date" class=" form-control pl-12" name="start_contract" value="{{ $project->start_contract }}">
                                </div>
                            </div>

                            <div class="col-span-12"> <label for="modal-form-1" class="form-label">Tanggal Akhir
                                    Kontrak</label>
                                <div class="relative">
                                
                                        <input type="date" class=" form-control pl-12" name="end_contract" value="{{ $project->end_contract }}">
                                </div>
                            </div>

                            <div class="col-span-12"> <label for="modal-form-6" class="form-label">PT
                                    Pemenang</label>
                                <select id="Editcompany_id" class="searchUser form-select" name="Editcompany_id" >
                                    <option disabled selected >-- Pilih Company --</option>
                                    <option value="" > Company Belum Di Tentukan </option>
                                    @foreach ($users as $user)
                                    <option value="{{ $user->id }}"  {{ $user->id == $project->company_id ? 'selected' : '' }}>{{ $user->name }}</option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="col-span-12"> <label for="modal-form-1"
                                    class="form-label">Principal</label>
                                <select id="Editprincipal_id" class="searchUser form-select" name="Editprincipal_id" >
                                    <option disabled selected >-- Pilih Principal --</option>
                                    <option value="" > Principal Belum Di Tentukan </option>
                                    @foreach ($users as $user)
                                    <option value="{{ $user->id }}"  {{ $user->id == $project->principal_id ? 'selected' : '' }}>{{ $user->name }}</option>

                                    @endforeach
                                </select>
                            </div>

                            <div class="col-span-12"> <label for="modal-form-1"
                                    class="form-label">Distributor</label>
                                    <select id="Editdistributor_id" class="searchUser form-select" name="Editdistributor_id" >
                                        <option disabled selected >-- Pilih Distributor --</option>
                                        <option value="" > Distributor Belum Di Tentukan </option>
                                        @foreach ($users as $user)
                                        <option value="{{ $user->id }}"  {{ $user->id == $project->distributor_id ? 'selected' : '' }}>{{ $user->name }}</option>
    
                                        @endforeach
                                    </select>
                            </div>

                            <div class="col-span-12"> <label for="modal-form-6" class="form-label">Status</label>
                                <select id="modal-form-6" class="form-select" name="project_status_id" required>
                                    <option disabled>Pilih Status</option>
                                    @foreach ($statuses as $status)
                                        <option value="{{ $status->id }}"
                                            {{ $status->id == $project->project_status_id ? 'selected' : '' }}>
                                            {{ $status->status }}
                                        </option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <!-- END: Modal Body -->

                        <!-- BEGIN: Modal Footer -->
                        <div class="modal-footer text-right">
                            <button type="button" data-dismiss="modal"
                                class="btn btn-outline-secondary w-20 mr-1">Cancel</button>
                            <button type="submit" class="btn btn-primary w-20">Send</button>
                        </div>
                    </form>
                    <!-- END: Form -->
                </div>
            </div>
        </div>
    @endforeach

script

function editForm(id) {
                $("#Edituser_id"+id).select2();
                $("#Editproject_manager_id"+id).select2();
                $("#Editbohir_id"+id).select2();
                $("#Editcompany_id"+id).select2();
                $("#Editprincipal_id"+id).select2();
                $("#Editdistributor_id"+id).select2();
               
            }

how to use select2 in form edit laravel?

I’m not sure what your question or problem is, can you please state the specific problem?