我有一个显示名单列表的表格,旁边有一个"编辑"按钮和隐藏的id值.单击"编辑"按钮将隐藏的id作为表单值发布并显示编辑页面,以便用户可以更改该人员的详细信息.很标准.
编辑细节并提交我正在使用验证器时.如果验证失败,则需要返回编辑页面并显示错误.问题是编辑页面需要通过POST方法获取Id值,但重定向似乎只使用GET方法,这导致"找不到控制器方法"错误,因为没有设置Get路由.
有谁知道如何通过POST而不是GET重定向回页面.目前我的代码如下:
public function postEditsave(){
...
if ($validator->fails())
{
return Redirect::to('admin/baserate/edit')
->withErrors($validator)
->withInput();
}else{
...
Run Code Online (Sandbox Code Playgroud)
谢谢
您无需使用 POST 即可进入编辑页面。您可以使用 GET 和路由参数,请查看: http: //laravel.com/docs/routing#route-parameters
您将有一个 GET 路由来显示编辑页面,以及一个 POST 路由来在用户提交表单时处理请求。
它看起来像这样(注意参数):
public function getEdit($id)
{
return View::make(....);
}
public function postEdit($id)
{
...
return Redirect::back()->withErrors($validator)->withInput();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10388 次 |
| 最近记录: |