【问题标题】:Laravel 5.5 issue arise during updating form values更新表单值期间出现 Laravel 5.5 问题
【发布时间】:2018-10-19 09:51:27
【问题描述】:

在路由目录下的web.php中,我定义了一个路由:Route::resource('myprofile','Administrator\MyProfileController');

在我的控制器中,我有更新功能:

public function update(Request $request, $id){
// bla bla 
}

在我的刀片文件中,我有以下代码;

{{ Form::open(array('url' => 'administrator/myprofile', 'class'=>'form-horizontal')) }}
  // bla bla bla
{{ Form::close() }}

提交表单后,我看到以下错误;

[App\Http\Controllers\Administrator\MyProfileController] 上不存在方法 [store]。

在这里,我不想存储/插入表单值。这些已经在 db 表中。我只想更新表单值。

【问题讨论】:

    标签: laravel laravel-5


    【解决方案1】:

    该错误表示你的控制器没有实现 store 成员函数。

    对资源控制器的 POST 请求调用该控制器的 store 方法。

    要发送 UPDATE 请求,您必须像这样覆盖 html 表单中的请求方法:

    <!-- _id : the resource id you want to update. -->
    {{ Form::open(array('url' => 'administrator/myprofile/_id', 'method' => 'PUT', 'class'=>'form-horizontal')) }}
      // bla bla bla
    {{ Form::close() }}
    

    希望对您有所帮助。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-16
    • 2020-07-04
    • 1970-01-01
    • 2018-03-22
    • 1970-01-01
    • 2021-05-31
    • 2018-02-11
    • 2018-10-18
    相关资源
    最近更新 更多