在提交验证错误后使用 with_input() 保留用户旧输入数据时出现此错误:
ErrorException 未定义的偏移量:0
重定向的代码是:
return Redirect::to('login')->with_input();
在提交验证错误后使用 with_input() 保留用户旧输入数据时出现此错误:
ErrorException 未定义的偏移量:0
重定向的代码是:
return Redirect::to('login')->with_input();
我不确定您使用的是哪个版本的 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
如果您使用的是 Laravel 4,则需要使用withInput
而不是with_input