Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the purpose of using method_field('PUT') or <input type="hidden" name="_method" value="PUT" /> In Laravel?

If I want to make an update request then i have to use?

{{ method_field('PUT') }}

Or

<input type="hidden" name="_method" value="PUT">
like image 859
无名小路 Avatar asked Dec 19 '22 05:12

无名小路


1 Answers

https://laravel.com/docs/5.4/routing#form-method-spoofing

HTML forms do not support PUT, PATCH or DELETE actions. So, when defining PUT, PATCH or DELETE routes that are called from an HTML form, you will need to add a hidden _method field to the form. The value sent with the _method field will be used as the HTTP request method:

If you're using only POST or GET routes, you won't need it.

like image 162
ceejayoz Avatar answered Feb 16 '23 00:02

ceejayoz