When I choosing multiple option in select box it make more than 1 id it store in different id I want to store all selected option in 1 id.
This is my create form
<form method="post" action="">
@csrf
<table>
<tr>
<td>Task Title : </td>
<td>
<select name="task_id" id="task_id">
@foreach ($tasks as $task)
<option value=""></option>
@endforeach
</select>
</td>
</tr>
<tr>
<td>Staff Name : </td>
<td>
<select name="staff_id" id="staff_id" multiple>
<option value=''>Select One</option>
@foreach ($staffs as $staff)
<option value=""></option>
@endforeach
</select>
</td>
</tr>
<tr>
<td>Done At :</td>
<td><input type="time" name="done_at" class="form-control"></td>
</tr>
<td><button class="btn btn-primary" name="submit" type="submit" value="submit" id="submit">Submit</button></td>
</table>
</form>
This is my store function where i storing data recieved from form
public function store(Request $request)
{
$request->validate([
// 'staff' => 'array|required',
'staff_id' => 'required',
'task_id' => 'required',
'done_at' => 'sometimes',
]);
$assignment = Assignment::create([
'task_id' => $request->input('task_id'),
'staff_id' => $request->input('staff_id'),
'done_at' => 'null',
]);
return redirect()->route('assignments.index', compact('assignment'))->withSuccess('Done');
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire