How can I redirect with old input in Laravel? How can I redirect with old input in Laravel? laravel laravel

How can I redirect with old input in Laravel?


You can access the last inputs like so:

$username = Request::old('username');

As pointed at by @Arian Acosta you may simply do

<input type="text" ... value="{{ old('username') }}" ... >.

As described in the docs it is more convenient in a blade view.


There are several possibilties in the controller:

Instead of ->withInput(Request::except('password'))

do:

a) Input::flash();

or:

b) Input::flashExcept('password');

and redirect to the view with:

a) ->withInput(Input::except('password'));

resp. with:

b) ->withInput();

The docs about Old Input for further reading...


You are missing the value on your input element...

value="{{ Input::get ('username', '') }}"


For my project, I needed another way:

Shove a GET request in the validation return to fetch some previous data:

   // if the validator fails, redirect back to the form    if ($validator->fails()) {        //let's send some data back (Orlando,Florida):        return Redirect::to('auth/register?city=Orlando&State=Florida')            ->withErrors($validator)    }else{     //validation success    }