Answer the question
In order to leave comments, you need to log in
How to correctly display values on a page in laravel?
Hi all.
There are 70 entries in the database.
I bring it out like this
@if(isset($questions))
<ul>
@foreach($questions as $question)
<li class="qName">{{ $question->question }}</li>
<ul>
<li><label><input name="a1" type="radio" value="a">Постоянно</label></li>
<li><label><input name="a2" type="radio" value="b">Иногда</label></li>
<li><label><input name="a3" type="radio" value="c">Время от времени</label></li>
</ul>
@endforeach
</ul>
@endif
Answer the question
In order to leave comments, you need to log in
Answer
<li><label><input name="answer_{{ $loop->iteration }}" type="radio" value="a">Постоянно</label></li>
<li><label><input name="answer_{{ $loop->iteration }}" type="radio" value="b">Иногда</label></li>
<li><label><input name="answer_{{ $loop->iteration }}" type="radio" value="c">Время от времени</label></li>
<input name="a{{$question->id}" type="radio" value="a">
If you don't understand what the error is, make a test page without a blade on pure HTML.
Your error is not in Laravel at all. Read here .
Well, for copy-paste - I would do something like this:
<li><label><input name="question[{{$question->id}}]" type="radio" value="a">Постоянно</label></li>
<li><label><input name="question[{{$question->id}}]" type="radio" value="b">Иногда</label></li>
<li><label><input name="question[{{$question->id}}]" type="radio" value="c">Время от времени</label></li>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question