Oct 22, 2018
0
Level 1
How to update data in a modal form
Hi to everyone, I have a problem in my app. In my blade file I have two modal. In the first modal with a foreach statement I show the row of a table in a db. Then in every row there's a button that open the second modal in which I can update the fields. The update function works, but even if I try to open different rows, I always see the first id.
This is the the modal:
@foreach($par as $p)
<form action="{{ route('anamUpdatePar', ['id' => $p->id_par]) }}" method="post" class="form-horizontal">
{{csrf_field()}}
{{ method_field('PUT') }}
<input class="form-control hidden" type="text" name="ids[]" value="{{ $p->id_parente }}" disabled>
<div class="modal fade" id="update_anam" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-sm">
<!--the rest of the modal-->
</form>
@endforeach
This is the route:
Route::put('/anami/{id}, AnamiController@update')->name('anamUpdatePar');
The variable $par contains all the ids stored in the table of db. I checked it with dd(). So what I have to do? Thanks!
Please or to participate in this conversation.