Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here
Tutorial Free

There's no PUT/PATCH/DELETE method, or how to build a Laravel form manually

July 07, 2015
2 min read

Laravel RESTful controller mechanism is a very convenient thing - we generate Controller, write {{ Form::xxxx() }} methods in Blade templates and it works like magic. But there's a little trick there which I want to talk about - it's PUT/PATCH/DELETE methods for updating the database entries.

Let's remember the theory first - here's how Laravel official documentation explains different methods for RESTful controllers:

0707_laravel_restful

If you are not using Laravel and want to build a form manually, you cannot use PUT/PATCH - there's just no such methods supported by forms in browsers - it's only GET and POST. So how does Laravel make it work with {{ Form::create(['method' => 'PUT']) }}?

Actually, under the hood the generated HTML looks like this:

<form accept-charset="UTF-8" action="" method="POST"><input name="_method" type="hidden" value="PUT"></form>

That's right, Laravel constructs a hidden field with name _method and then checks it upon form submittion, routing it to the correct Controller method.

So if for any reason you would need to build the FORM tag yourself, don't put <form method="put"> (same applied to patch and delete) - it just won't work. Instead add hidden fields, if necessary.

Enjoyed This Tutorial?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

Comments & Discussion

No comments yet…