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

Sadon's avatar
Level 1

How to edit only 1 row on laravel for each loop

I am using livewire to inline edit the table data.

        @foreach($tags as $index => $tag)
            <form>
                <input type="hidden"
                       name="id"
                       wire:model="ids"/>
                <tr class="row d-flex flex-row justify-content-between">
                    <td class="border-0 namePart">
                        @if($editable !== true)
                            {{$tag['name']}}
                        @else
                            <input type="text"
                                   wire:model.defer="editName"/>
                            @error('editName')
                            <span class="invalid-feedback d-block">{{ $message }}</span> @enderror
                        @endif
                    </td>

Everything works fine. The only problem is when editing every row looks the same but after i hit save button it works. Does anyone have some suggestion

0 likes
1 reply
Tray2's avatar

Check that you have the corerect action in the form and that you pass the id of whatever it is you are updating to the route and handle it properly in the controller.

Please or to participate in this conversation.