如何使用输入重定向回表单 - Laravel 5 [英] How to redirect back to form with input - Laravel 5

查看:21
本文介绍了如何使用输入重定向回表单 - Laravel 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的表单操作引发异常,我如何使用给定的 POST 参数重定向回我的表单页面?

解决方案

您可以使用以下内容:

return Redirect::back()->withInput(Input::all());

如果您使用表单请求验证,这正是Laravel 如何将您重定向回错误和给定的输入.

摘自 IlluminateFoundationValidationValidatesRequests:

<块引用>

return redirect()->to($this->getRedirectUrl())->withInput($request->input())->withErrors($errors, $this->errorBag());

How do I redirect back to my form page, with the given POST params, if my form action throws an exception?

解决方案

You can use the following:

return Redirect::back()->withInput(Input::all());

If you're using Form Request Validation, this is exactly how Laravel will redirect you back with errors and the given input.

Excerpt from IlluminateFoundationValidationValidatesRequests:

return redirect()->to($this->getRedirectUrl())
                    ->withInput($request->input())
                    ->withErrors($errors, $this->errorBag());

这篇关于如何使用输入重定向回表单 - Laravel 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆