Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gust's avatar
Level 1

How to send questions with choices into controller thru post request properly

I am making a quiz site, I currently have a form createQuestions.blade.php where I create 1 question text+label and 4 question choices

      <div class="col-md-6 col-md-offset4">
                {!! Form::open(['route' =>'quiz.storeQuestions']) !!}
                @for($i = 0;$i < $questions;$i++)
                    {{Form::label('question'.($i+1).'','Question '.($i+1).'',array('class' => 'questionTitle tab'))}}
                    {{Form::text('question'.($i+1).'',null,array('class' => 'form-control tab','placeholder' => 'Question Title'))}}
                    <br>
                    @for($j = 0;$j < 4;$j++)
                        {{Form::label('choice'.($i+1).'','Choice '.($i+1).':',array('class'=>'tab'))}}
                       <span class="correct">Correct </span>{{Form::radio('correct'.($i +1).'')}}
                        {{Form::text('choice'.($i+1).'',null,array('class' => 'form-control tab'))}}
                    @endfor
                    <br>
                @endfor
                <br>
                {{Form::submit('Add Questions',array('class' => 'tab'))}}
                {!! Form::close() !!}
            </div>

I want to be able to access Each question's text and each question's text

    public function storeQuestions(Request $request)
    {
        $questionsArray= array();
        for($i = 0; $i < 19;$i++){
            $questionsArray[$i] = $request->question.($i+1);
        }
        dd($questionsArray);
    }

This isn't giving the question's text How do I get the question's text?

0 likes
0 replies

Please or to participate in this conversation.