1

在此处查看有关旧输入的文档

Route::post('/search/all/', function (Request $request) {

 //...

  $products = $query->paginate(15);
  $data = ['products' => $products,
  'oldinput' => $request->all()];


  return view('inventory.search_products', $data);
});

在视图中:

这有效:

<input type="text"  id="search_all" name="search_all" value="{{ $oldinput['search_all'] }}">

这总是空的:

<input type="text"  id="search_all" name="search_all"  value="{{ old('search_all') }}">
4

3 回答 3

2

文档说你应该flash()调用old()方法。

flashing 将先前的请求存储在会话中。old(search_all)所以这行不通是有道理的

于 2016-09-02T23:33:06.310 回答
2

只需调用flush您的控制器,然后您就可以在您的刀片old()中使用辅助功能。

 public function YourController(Request $request){
     $request->flash();
 return view('yourblade');
}

在刀片文件中:-

<input id="lng" name="lng" value="{{old('lng')}}"  type="hidden">
于 2019-01-18T07:23:19.157 回答
2

我将建议以下解决方案:

return view('inventory.search_products', $data)->withInput(\Input::all());

在刀片中你也可以调用\Input::old('search_all');

于 2016-09-03T00:29:04.347 回答