Reputation: 53
I'm getting this error when using with_input() to keep the user old input data after submiting with validation errors:
ErrorException Undefined offset: 0
the code for redirect is:
return Redirect::to('login')->with_input();
Upvotes: 0
Views: 4611
Reputation: 5387
I am not sure which version of Laravel you are using, but your code should be:
return Redirect::to('login')->withInput();
and if you are returning errors too, you might consider using withErrors()
in addition:
Route::post('register', function()
{
$rules = array(...);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
return Redirect::to('register')->withErrors($validator);
}
});
Check the docs: http://laravel.com/docs/validation#error-messages-and-views
Upvotes: 2
Reputation: 8595
If you're using Laravel 4, you need to use withInput
instead of with_input
Upvotes: 1