Use only one checkbox for that.
<input type="checkbox" name="required[{{ $skill->id }}]" value="1">
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a table with 2 columns of checkboxes; 1 for Select and 1 for Required.
<thead>
<tr>
<th>Select</th>
<th>Required?</th>
<th data-sortable="true">Skill</th>
</tr>
</thead>
<tbody>
@foreach($skills as $skill)
<tr>
<td><input type="checkbox" name="skill_id[]" value="{{ $skill->id }}"></td>
<td><input type="checkbox" name="required[]" value="1"></td>
<td>{{ $skill->skill_name }}</td>
</tr>
@endforeach
</tbody>
When I dd($request) in my controller...
"skill_id" => array:2 [▼
0 => "2"
1 => "5"
]
"required" => array:1 [▼
0 => "1"
]
For example I selected skill_id #2 and #5 but only required #5. As you can see the checkbox arrays are not connected / linked letting me know which was required. How can I link them in my request?
Thanks for the help!
I have found a way to make it work... one checkbox is for "required" and the other checkbox is for "optional". I then loop through each array in my controller insert the record and updating the required field accordingly. Not ideal, but it will work. Thanks for the help.
Please or to participate in this conversation.