Where are the radio inputs?
Oct 18, 2020
7
Level 2
get value multiple radio
Hi there,
I'm trying to build a quiz and there are 5 questions. Each question has 3 choices and 1 choice is correct. 1 selection is possible.
I'm trying to get the selected choices but my request()->all(); return empty array ....
Can you help me please?
Thank you
my html
<div class="quiz-box__questions-list">
@foreach($quiz->questions as $key => $question)
<div class="quiz-box__question-box">
<span class="quiz-box__question-number">Question {{$question->question_identifier .' / '. $quiz->questions->count() }}</span>
<p class="quiz-box__question">{{$question->question}}</p>
@if(!empty($question->illustration))
<figure>
<img class="quiz-box__question-illustration" src="{{$question->illustration}}" alt="">
</figure>
@endif
<div class="quiz-box__choices-list">
@php
$choices = App\Models\Choice::where('question_identifier', $question->question_identifier)->where('quiz_id', $quiz->id)->get();
@endphp
@foreach($choices->shuffle()->all() as $choice)
<label class="quiz-box__choice uk-card uk-card-default">
<input class="quiz-box__radio" type="radio" name="question_{{$question->question_identifier}}_choice" value="{{$choice->id}}">
<div class="quiz-box__choice-description">
<div class="quiz-box__choice-letter-box">
A
</div>
<div class="quiz-box__choice-answer-box">
<p class="quiz-box__choice-answer">{{$choice->choice}}</p>
</div>
</div>
</label>
@endforeach
</div>
<div class="uk-alert-danger" uk-alert>
<a class="uk-alert-close"></a>
<p>lorem ipsum</p>
</div>
</div>
<hr class="quiz-box__divider">
@endforeach
</div>
Level 2
Please or to participate in this conversation.