在 laravel 5 中的表单请求验证后传递旧输入
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29214413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pass old input after Form Request validation in laravel 5
提问by GabAntonelli
if the validation fails it's not clear to me how i could pass the old input to fill again the form.
如果验证失败,我不清楚如何通过旧输入重新填写表单。
I mean, I know how to pass the data when using the Validator class and redirecting after fail with the method withInput(), but I'm trying to learn how to use Form Requests provided in laravel 5. Thanks
我的意思是,我知道如何在使用 Validator 类时传递数据,并在使用 withInput() 方法失败后重定向,但我正在尝试学习如何使用 laravel 5 中提供的表单请求。谢谢
回答by Limon Monte
$username = Request::old('username');
or in view:
或认为:
{{ old('username') }}
回答by Naveen dev
You can redirect with old data like below with validation error
您可以使用验证错误如下所示的旧数据重定向
return redirect()->back()->withErrors($validator)->withInput();