mardi 17 juillet 2018

Inserting Multiple Checkbox value with laravel

I am trying to submit a form with multiple checkbox values into my user_answer column
My Controller

public function store(Request $request) {

    $input = $request->all();
    //dd($input);

    Answer::create($input);
    return back()->with('added', 'Answer has been submitted');
}

My View

        @elseif($question->question_type == "$check_a" )
            <div>
            <span class="question-title">{!! $question->question !!}</span>
                <ul class="question-choices">
                    <li>
                        <label>
                            {!! Form::checkbox('user_answer[]', 'A'); !!} {!! $question->a !!}
                        </label>
                    </li>
                    <li>
                        <label>
                            {!! Form::checkbox('user_answer[]', 'B'); !!} {!! $question->b !!}
                        </label>
                    </li>
                
                @if (!empty($question->c))
                    <li>
                        <label>
                            {!! Form::checkbox('user_answer[]', 'C'); !!} {!! $question->c !!}
                        </label>
                    </li>
                @else
                
                @endif




Aucun commentaire:

Enregistrer un commentaire