Retrieve the values of the fields when going back to laravel

1

I am using laravel 5.4 I am validating the form with the Valitador:make , what I want to know is that when a failure occurs and I go back I could show the value that the fields had before to reload the page, instead of empty input .

This is the code that I use for the validations in the user's driver when entering a new user

$messages = [
        'unique' => 'El :attribute ya existe',
    ];

    $validator = Validator::make($request->all(), [
        'username' => 'required|unique:users|max:255',
        'email' => 'required|unique:users|max:255',
    ], $messages);

    if ($validator->fails()) {
       return redirect('users')->withErrors($validator, 'SaveUser')->withInput();
    }
    
asked by Carlos Alexander Lemus Mojica 06.06.2017 в 17:27
source

1 answer

0

Although some information may be missing to better focus the context, in general if you want to show the entered values you must add the helper {{ old('campo') }} to the value of the field:

<input type="text" name="nombre" value="{{ old('nombre') }}">

You can find more information in the Laravel documentation: link

    
answered by 06.06.2017 / 17:52
source