0

在提交验证错误后使用 with_input() 保留用户旧输入数据时出现此错误:

ErrorException 未定义的偏移量:0

重定向的代码是:

return Redirect::to('login')->with_input();
4

2 回答 2

2

我不确定您使用的是哪个版本的 Laravel,但您的代码应该是:

return Redirect::to('login')->withInput();

如果您也返回错误,您可以考虑withErrors()另外使用:

Route::post('register', function()
{
    $rules = array(...);

    $validator = Validator::make(Input::all(), $rules);

    if ($validator->fails())
    {
        return Redirect::to('register')->withErrors($validator);
    }
});

检查文档: http: //laravel.com/docs/validation#error-messages-and-views

于 2013-10-16T02:23:02.887 回答
1

如果您使用的是 Laravel 4,则需要使用withInput而不是with_input

于 2013-10-16T02:21:31.737 回答