I have a list of articles and I put a submit button to all of them.
The fact is I can't get the good input hidden when I'm in my controller because it will take the last input.
<form method="POST" action="{{url('/deleteArticle')}}">
@foreach($articles as $a)
{{ csrf_field() }}
<div class="test">
<div class="name"><?= $a['name_a'] ?></div>
<input type="hidden" name="id" id="ida" value='<?= $a['id_a'] ?>'/>
<input type="submit" class="del" id="delA" class="cross" name="id">X</input>
</div>
@endforeach
</form>
Instead of doing the trick with javascript, I thought about looping my articles and foreach of them having a form.
Is it a bad practice or should I have a single form with one submit button by article? The value of this submit button can't be "X" but only the ID of my article I want to delete, and this is bad for the display.