Laravel form html with PUT method for PUT routes Laravel form html with PUT method for PUT routes php php

Laravel form html with PUT method for PUT routes


If you are using HTML Form element instead Laravel Form Builder, you must place method_field between yourform opening tag and closing end. By doing this you may explicitly define form method type.

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


Just use like this somewhere inside the form

@method('PUT')


You CAN add css clases, and any type of attributes you need to blade template, try this:

{{ Form::open(array('url' => '/', 'method' => 'PUT', 'class'=>'col-md-12')) }}.... wathever code here{{ Form::close() }}

If you dont want to go the blade way you can add a hidden input. This is the form Laravel does, any way:

Note: Since HTML forms only support POST and GET, PUT and DELETEmethods will be spoofed by automatically adding a _method hidden fieldto your form. (Laravel docs)

<form class="col-md-12" action="<?php echo URL::to('/');?>/post/<?=$post->postID?>" method="POST">    <!-- Rendered blade HTML form use this hidden. Dont forget to put the form method to POST -->    <input name="_method" type="hidden" value="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>