Level 122
@jlrdw we've done that bit
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
@jlrdw we've done that bit
This line
<input type="hidden" name="question_id" value="{{$answer->id}}">
is inside the foreach answers loop in the form. It will be overwritten each time around the loop
Have you changed this to name="question_id[]" by any chance?
Here is an example working 100%, not in laravel, but php whipped up quickly:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="z" id="z" method="post" action="apost.php" >
<label>Multiple Selection </label> </td>
<?php
$x = 1;
while ($x <= 2) {
$cars = 'cars' . (string) $x;
?>
<select name="<?= $cars; ?>[]" size="10" multiple="multiple" tabindex="1">
<option value="11">eleven</option>
<option value="12">twelve</option>
<option value="100">hello</option>
<option value="14">fourteen</option>
<option value="15">fifteen</option>
<option value="16">sixteen</option>
</select>
<?php
$x++;
}
?>
<input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>
<?php
foreach ($_POST['cars1'] as $selectedOption)
echo $selectedOption . "\n";
echo '<br>';
echo '<br>';
echo '<br>';
echo '<br>';
foreach ($_POST['cars2'] as $selectedOption)
echo $selectedOption . "\n";
?>
Works, just test of the dropdown, other fields should be self explanatory.
There are times when a little trial and error works the problem out.
Please or to participate in this conversation.