View code
@foreach($questions as $question)
<input type="hidden" name="question[]" value="">
<textarea name="answers[]"></textarea>
@endforeach
Controller Code
public function finishExam(Request $request)
{
foreach ( $request->get('question') as $answer) {
$answers[] = [
'quiz_id' => $quiz->id,
'user_id' => $user_record->id,
'written_question_id' => $answer->question,
'answers' => $answer->answers
];
}
WrittenResult::insert($answers);
}
Error Showing when submission the form
Array showing when print as var_dump or print_r
$items = array();
foreach($request as $username) {
$items[] = $username;
}
print_r($items);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire