Radio Button back with the old value

1

Hello

I have the following code:

     <div class="resposta">
        <label class="radio-inline" style="padding-right: 20px;">
            <input type="radio" name="1" value="S" {{ old('resposta1') == "S" ? 'checked' : '' }}>SIM
        </label>
        <label class="radio-inline">
            <input type="radio" name="1" value="N" {{ old('resposta1') == "N" ? 'checked' : '' }}>N&atilde;o
        </label>
    </div>

In my controller I'm doing the Validator:

    $resposta1 = $request->input( '1' );
    $resposta2 = $request->input( '2' );
    $resposta3 = $request->input( '3' );

    $validator = Validator::make(
        [
          'resposta1' => $resposta1,
          'resposta2' => $resposta2,
          'resposta3' => $resposta3,
        ],
        [
           'resposta1' => 'required',
           'resposta2' => 'required',
           'resposta3' => 'required'
        ]
    );

    if( $validator->fails() ){
         return redirect()->back()->withErrors( $validator )->withInput();
    }

I would like you to make a mistake if you check the radios once they have been checked.

But my code is not working

    
asked by anonymous 08.03.2018 / 20:11

0 answers