Php Laravel表单html,带有用于PUT路由的PUT方法

Php Laravel表单html,带有用于PUT路由的PUT方法,php,forms,laravel,routes,put,Php,Forms,Laravel,Routes,Put,我在我的路线中有: +--------+---------------------------+--------------+--------------------------- ---------+----------------+---------------+ | Do

我在我的路线中有:

+--------+---------------------------+--------------+---------------------------                                                                                                                ---------+----------------+---------------+
| Domain | URI                       | Name         | Action                                                                                                                                             | Before Filters | After Filters |
+--------+---------------------------+--------------+---------------------------                                                                                                                ---------+----------------+---------------+
|        | GET|HEAD /                |              | postcontroller                                                                                                                                     | auth           |               |
|        | GET|HEAD login            |              | homecontroller@dologin                                                                                                                             |                |               |
|        | POST login                |              | homecontroller@dologin                                                                                                                             |                |               |
|        | GET|HEAD logout           |              | homecontroller@dologout                                                                                                                            |                |               |
|        | GET|HEAD post             | post.index   | postcontroller@index                                                                                                                               |                |               |
|        | GET|HEAD post/create      | post.create  | postcontroller@create                                                                                                                              |                |               |
|        | POST post                 | post.store   | postcontroller@store                                                                                                                               |                |               |
|        | GET|HEAD post/{post}      | post.show    | postcontroller@show                                                                                                                                |                |               |
|        | GET|HEAD post/{post}/edit | post.edit    | postcontroller@edit                                                                                                                                |                |               |
|        | PUT post/{post}           | post.update  | postcontroller@update                                                                                                                              |                |               |
|        | PATCH post/{post}         |              | postcontroller@update                                                                                                                              |                |               |
|        | DELETE post/{post}        | post.destroy | postcontroller@destroy 
现在,我想制作一个使用PUT方法的表单html。这是我的密码:

<form class="col-md-12" action="<?php echo URL::to('/');?>/post/<?=$post->postID?>" method="put">
    <div class="form-group">
        <textarea type="text" class="form-control input-lg" placeholder="Text Here" name="post"><?=$post->post?></textarea>
    </div>
    <div class="form-group">
        <button class="btn btn-primary btn-lg btn-block" type="submit" value="Edit">Edit</button>
    </div>
</form>     
但是,我希望表单仍然可以通过CSS样式完成。 伙计们,有什么解决办法吗?
谢谢

在您的视图中,将刀片更改为

{{ Form::open(['action' => 'postcontroller@edit', 'method' => 'PUT', 'class' = 'your class here']) }}

<div>
{{ Form::textarea('textareanamehere', 'default value here', ['placeholder' => 'your place holder here', 'class' => 'your class here']) }}
</div>

<div>
{{ Form::submit('Update', ['class' => 'btn class here'])}}
</div>

{{ Form::close() }}
{{Form::open(['action'=>'postcontroller@edit“,”方法“=>”放置“,”类“='您的类在这里]])}
{Form::textarea('textareanamehere','defaultvalue here',['placeholder'=>'您的占位符here','class'=>'您的类here'])}}
{{Form::submit('Update',['class'=>'btn class here'])}
{{Form::close()}}
实际上,你可以使用原始形式,比如你的问题。但我不推荐。dan itulah salah satu alasan agan belajar框架,简单,dan cepat。因此,卡纳帕·帕克的生食形式更为独特。呵呵。作为印尼人感到自豪


参考:

您可以添加css类别,以及需要添加到刀片模板的任何类型的属性,请尝试以下操作:

{{Form::open(数组('url'=>'/','method'=>'PUT','class'=>'col-md-12'))}
.... 这里是wathever代码
{{Form::close()}}
如果你不想走刀片式的道路,你可以添加一个隐藏的输入。这是Laravel的工作方式,不管怎样:

注意:由于HTML表单只支持POST和GET、PUT和DELETE 方法将通过自动添加_method隐藏字段进行欺骗 以你的形式


如果您使用的是HTML表单元素而不是larvel表单生成器,则必须在
形成开始标记和结束标记。通过这样做,您可以显式定义表单方法类型

<form>
{{ method_field('PUT') }}
</form>

{{method_字段('PUT')}

只需在表单中的某个地方这样使用即可

@method('PUT')

非常简单,您只需要像这样使用
方法\u字段('PUT')

HTML

<form action="{{ route('route_name') }}" method="post">
    {{ method_field('PUT') }}
    {{ csrf_field() }}
</form>

{{method_字段('PUT')}
{{csrf_field()}}

<form action="{{ route('route_name') }}" method="post">
    <input type="hidden" name="_method" value="PUT">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>

问候


<form action="{{url('/url_part_in_route').'/'.$parameter_of_update_function_of_resource_controller}}"  method="post">
@csrf
<input type="hidden" name="_method" value="PUT">    //   or @method('put')          
....    //  remained instructions                                                                              
<form>
@csrf //或@method('put')) .... // 剩余指令
这两种方法在v5.4中都不起作用。当您将版本更改为5.4时,上面链接的表单和HTML页面为空,这是laravel 5.7的官方版本。您可以使用
@method('PUT')
进行
<form action="{{url('/url_part_in_route').'/'.$parameter_of_update_function_of_resource_controller}}"  method="post">
@csrf
<input type="hidden" name="_method" value="PUT">    //   or @method('put')          
....    //  remained instructions                                                                              
<form>