In the applications, there are 2 tabs:
- Personal Details
- Interview Questions
In the interview questions, it is a setup coming from configurations and there is a radio button "Yes" or "No"
In this example,
In question # 1, I choose "Yes" but the value changed in question # 3 not in the question # 1.
Below is my code for in getting the interview questions
Controller
public $interivew_questions = [];
public $answers = [];
$interview_questions = InterviewQuestions::where('company_id', Auth::user()->company_id)
->where('active',1)
->get();
foreach ($interview_questions as $i_q => $interview_question) {
# code...
$this->interview_questions[] =
[
'remarks' => $interview_question->remarks,
'answer' => "",
];
}
View
<?php $counter = 0; ?>
@foreach($interview_questions as $i_q => $interview_question)
<?php $counter++; ?>
<div class="row mb-3">
<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1">
<span style="font-weight: bolder; display: inline;">{{ $counter }}.</span>
</div>
<div class="col-xs-11 col-sm-11 col-md-11 col-lg-11">
<p wire:model="interview_questions.{{$i_q}}.remarks"> {{ $interview_question['remarks'] }}</p>
</div>
</div>
<div class="row mb-3">
<div class="col-xs-5 col-sm-5 col-md-5 col-lg-5 offset-md-1 offset-xs-1 offset-sm-1 offset-lg-1">
<label>
<input type="radio" wire:model="answers" name="answers" value="YES" /> YES
<!-- <input type="radio" wire:model="interview_questions.{{$i_q}}.answer" name="answers" value="YES" /> YES -->
</label>
<label>
<input type="radio" wire:model="answers" name="answers" value="NO" /> NO
<!-- <input type="radio" wire:model="interview_questions.{{$i_q}}.answer" name="answers" value="NO" /> NO -->
</label>
</div>
</div>
@endforeach
UPDATED POST
I removed the name in my input field, it is now getting the correct answer in corresponding questions but it can now check both "Yes" or "No"
Question: How do I get the correct answer for corresponding question #?
