Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AwadGorg's avatar

set value to input field in Livewire

Hello, I have this input field inside my code that I want to set the value to an id of an object to be specific but Livewire prevent doing so I just want to know how can I do so send the id with the request.

this is the code am using

        @forelse($scanRequests as $request)
        <tr>
            <td>{{$loop->iteration}}</td>
            <td>{{$request->created_at->format('Y-m-d')}}</td>
            <td>{{$request->service->name}}</td>
            <td></td>
            <td></td>
            <td>
                <div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="card">
                                <div class="card-body">
                                    <div class="d-flex justify-content-center">
                                        <button type="button" class="btn btn-primary" data-toggle="modal"
                                            data-target="#exampleModal_{{ $request->id }}">
                                            <i class="fa-solid fa-file-circle-plus"></i>
                                        </button>
                                        @if (!empty($request->file))
                                        <button type="button" class="btn btn-primary ml-2" data-toggle="modal"
                                            data-target="#exampleModal_show_{{ $request->id }}">
                                            <i class="fa-solid fa-eye"></i>
                                        </button>
                                        @endif
                                    </div>
                                    {{-- edit model start here --}}
                                    <div wire:ignore.self class="modal fade" id="exampleModal_{{ $request->id }}"
                                        tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
                                        aria-hidden="true">
                                        <div class="modal-dialog" role="document">
                                            <div class="modal-content">
                                                <x-alert></x-alert>
                                                <div class="modal-header">
                                                    <h5 class="modal-title" id="exampleModalLabel_{{ $request->id }}">
                                                        اضافة مرفق
                                                    </h5>
                                                    <button type="button" class="close" data-dismiss="modal"
                                                        aria-label="Close">
                                                        <span aria-hidden="true close-btn">×</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">
                                                    <div class="fild-control">
                                                        رقم المرفق
                                                        <input type="text" id="pation_id" class="d-none"
                                                            wire:model.lazy='pation_id' value="{{ $request->id }}">
                                                    </div>
                                                    <div class="fild-control mt-1">
                                                        <label for="file">اضافة مرفق</label>
                                                        <input type="file" class="form-control" name="file" id="file"
                                                            wire:model.lazy="file">
                                                    </div>
                                                    <div class="fild-control mt-1">
                                                        <label for="dr_content">رسالة الفني المختص</label>
                                                        <textarea class="form-control border-1 table-bordered"
                                                            name="dr_content" id="dr_content" rows="3"
                                                            wire:model.lazy="dr_content"></textarea>
                                                    </div>
                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-secondary close-btn"
                                                        data-dismiss="modal">اغلاق</button>
                                                    <button type="submit" wire:click.prevent="storeFile"
                                                        class="btn btn-primary close-modal">حفظ</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    {{-- edit model end here --}}
                                    {{-- show model start here --}}
                                    <div wire:ignore.self class="modal fade" id="exampleModal_show_{{ $request->id }}"
                                        tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
                                        aria-hidden="true">
                                        <div class="modal-dialog" role="document">
                                            <div class="modal-content">
                                                <x-alert></x-alert>
                                                <div class="modal-header">
                                                    <h5 class="modal-title" id="exampleModalLabel_{{ $request->id }}">
                                                        عرض مرفق
                                                    </h5>
                                                    <button type="button" class="close" data-dismiss="modal"
                                                        aria-label="Close">
                                                        <span aria-hidden="true close-btn">×</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">
                                                    <div>
                                                        <a href="{{ asset('uploads/'.$request->file) }}" download="">
                                                            <img src="{{ asset('uploads/'.$request->file) }}"
                                                                class="w-100 h-100" alt="">
                                                        </a>
                                                    </div>
                                                    <div class="fild-control mt-2">
                                                        <label for="dr_content">رسالة الفني المختص</label>
                                                        {{ $request->dr_content }}
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    {{-- show model end here --}}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                {{-- <button class="btn btn-primary btn-sm">
                </button> --}}

            </td>
        </tr>
        @empty
        <tr>
            <td colspan="5">لايوجد طلبات</td>
        </tr>
        @endforelse

and this is the input field

<input type="text" id="pation_id" class="d-none"
                                                            wire:model.lazy='pation_id' value="{{ $request->id }}">
0 likes
1 reply
Snapey's avatar

use wire:model OR set the value not both. If using wire:model set the value in the component

Please or to participate in this conversation.