How to fetch dynamic textfield name field in laravel

Posted 4 months ago by Deekshith

Hi Guys, I have a form with dynamic input fields like below,

{{ csrf_field() }} @foreach($get_contest_detail->questions as $que)
                    <p>{!! $que->question !!}</p>
                    <textarea rows="4" cols="50" id="question{{$que->id}}" name="question{{$que->id}}" class="form-control" required></textarea>

                

                    @endforeach

                    <input type="submit" class="btn btn-primary btn-sm" value="Submit" />

                </form>

I can submit the form in post controller function I can see all posted form fields like below,

{"_token":"sOryMBs3rQEKpcjgRFQ8eNbDFfrkPVaHaGjDKvBu","question2":"sdfsdfsdf","question3":"sdsdfsdf"}

So now I am trying to fetch above the field in laravel in know how to do that in normal forms like below, $request->question. But how can i fetch dynamic form fields like above? I tried below code but it is not working.

foreach($get_contest_detail->questions as $que) {

        if(is_null($request->question.''.$que->id))
        {
            return back()->withErrors('Please fill all questions.');
        }
        
    }

Please sign in or create an account to participate in this conversation.