【问题标题】:Laravel redirect back to wildcard valueLaravel 重定向回通配符值
【发布时间】:2013-05-28 15:02:49
【问题描述】:

尝试路由回包含验证检查错误的页面。这不起作用,这样做的正确方法是什么?

$route = "staff/" . $staff->staff_id;

return Redirect::to_route($route)
->with_errors($validation);

【问题讨论】:

  • 将它作为数组传递我的错误:return Redirect::to_route('staff', array($staff->staff_id)) ->with_errors($validation);

标签: php routing laravel


【解决方案1】:

你可以试试这个重定向回来(假设 Laravel 3)

return Redirect::back()->with_errors($validation);

或者这个

return Redirect::back()->with_errors($validation)->with_input();

所以,路线就不用说了,这是在我的一个项目上测试的。

【讨论】:

  • 在使用->with_input() 时是否需要Input::flash()? (与问题无关,只是想在这里问)
  • @itachi,不,您将在视图中使用Input::old('field_name')
  • 非常好,这是 Laravel 4 的 Redirect::back()->withErrors($validation)->withInput()
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-03
  • 2016-05-11
  • 2020-09-27
  • 2015-11-04
  • 2018-10-03
相关资源
最近更新 更多