Reputation: 67
I'm trying to submit a simple form but it's not redirecting or anything.
Code:
@foreach($admins as $admin)
<form method="post" action="/admin/medewerkers">
{{csrf_field()}}
<input type="text" value="{{$admin->id}}" name="userid" hidden>
<tr>
<td>{{$admin->name}}</td>
<td>{{$admin->email}}</td>
<td><a data-target="#myModal{{$admin->id}}" data-toggle="modal"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> </a> </td>
<td> <button type="submit" class="btn btn-xs btn-danger" name="delete" id="delete"> Delete </button></td>
</tr>
</form>
@endforeach
Simple backend
public function update(Request $request)
{
if (isset($_POST['delete'])) {
echo 'delete';
}
}
What am i doing wrong here? Thanks!
Upvotes: 0
Views: 57
Reputation: 16436
You can't use form containing <tr> only
try this:
@foreach($admins as $admin)
<tr>
<td>{{$admin->name}}</td>
<td>{{$admin->email}}</td>
<td><a data-target="#myModal{{$admin->id}}" data-toggle="modal"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> </a> </td>
<td> <form method="post" action="/admin/medewerkers">
{{csrf_field()}}
<input type="text" value="{{$admin->id}}" name="userid" hidden>
<button type="submit" class="btn btn-xs btn-danger" name="delete" id="delete"> Delete </button> </form>
</td>
</tr>
@endforeach
Upvotes: 1