UsersController:
public function update($id)
{
if( ! $this->user->isValid(Input::all()))
{
return Redirect::back()->withInput()->withErrors($this->user->errors);
}
$user = $this->user->find($id);
$user->save();
return Redirect::route('users.index');
}路由:
Route::resource('users','UsersController');型号:
protected $table = 'users'edit.blade.php:
{{ Form::model($user, array('route'=>array('users.update','$user'=>'id'))) }}我注意到这不会生成"PUT“操作。网页来源:
<form method="POST" action="https://zocios.com/users/id" accept-charset="UTF-8"><input name="_token" type="hidden" value="...">按“更新用户”按钮可以让我:
Exception \ MethodNotAllowedHttpException问题是"$user->save();“吗?我还做错了什么吗?谢谢!
发布于 2014-06-24 19:00:50
您需要指定方法:
{{ Form::model($user, array('method' => 'put', 'route'=>array('users.update','$user'=>'id'))) }}除了GET和POST之外,没有其他方法是可以接受的(尽管有规范),因此框架可以在表单_method中标识隐藏输入以使其工作。
https://stackoverflow.com/questions/24393665
复制相似问题