为什么使用 PUT 方法提交表单我收到 GET 请求?

mst*_*std 1 laravel-5

在我的 laravel 5.7 应用程序中,我制作了用于更新数据的表单,例如:

<section class="card-body">
    <h4 class="card-title">Edit vote</h4>


    <form method="PUT" action="{{ url('/admin/votes/update/'.$vote->id) }}" accept-charset="UTF-8" id="form_vote_edit" class="form-horizontal"
          enctype="multipart/form-data">
        {!! csrf_field() !!}
        <ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
Run Code Online (Sandbox Code Playgroud)

在routes/web.php中用餐的路线:

Route::group(['middleware' => ['auth', 'isVerified', 'CheckUserStatus'], 'prefix' => 'admin', 'as' => 'admin.'], function () {
    ...
    Route::put('/votes/update/{vote_id}', 'Admin\VotesController@update');
Run Code Online (Sandbox Code Playgroud)

但提交表格时我收到错误请求:

Request URL: http://local-votes.com/admin/votes/update/22?_token=0CEQg05W4jLWtpF3xB6BGSdz1icwysiDOStLVgHv&id=22&name=gg...
Request Method: GET
Status Code: 405 Method Not Allowed
Run Code Online (Sandbox Code Playgroud)

为什么 GET 请求,我的表单有什么问题?

谢谢!

Rem*_*mul 5

HTML 表单仅支持GETPOST.

来自文档:

由于 HTML 表单无法发出 PUT、PATCH 或 DELETE 请求,因此您需要添加一个隐藏的 _method 字段来欺骗这些 HTTP 动词。

您可以使用method_field帮助程序或@method Blade 指令来添加隐藏输入。

<form action="/foo/bar" method="POST">
    @method('PUT')
    ...
</form>
Run Code Online (Sandbox Code Playgroud)

或者

<form action="/foo/bar" method="POST">
    {{ method_field('PUT') }}
    ...
</form>
Run Code Online (Sandbox Code Playgroud)