Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AdeMike's avatar

How to submit Checkboxes at once to different rows

I needed to submit attendence at once using checkboxes, but i keep getting error... in my view i have this, i have about 100 students..

<tbody>
      <form method="POST" action="{{Route('attendance.store')}}">
             @foreach ($students as $student )
                   <tr>
                         <td>{{$student->name}}</td>
                         <td> <input type="hidden" name="name[]" value="{{$student->id}}" />
                                  <input type="checkbox" name="value[Number 1]" value="{{$student->id}}" />
                        </td>
                  </tr>
          @endforeach
         <tr>
               <td><button type="submit">SUbmit </button></td>
          </tr>
</form>
</tbody>

The Controller

public function storeStudentAttendance(Request $request)
    {


        $values = $request->get('value');
        foreach ($request->get('name') as $name) {

            $newValue = $values[$name] ?? 0;
        }

        ddd($newValue);
    }

I want to save the each attendance into different roles for different student

0 likes
2 replies
martinbean's avatar

but i keep getting error

@ademike Right? So what’s the error? Or do we have to guess…?

1 like
jlrdw's avatar

@ademike also the checkboxes not checked won't be in the request array.

1 like

Please or to participate in this conversation.