Support the ongoing development of Laravel.io →
Requests Blade Forms
Last updated 2 years ago.
0

The only methods that are valid within a form tag are "GET" and "POST". Since "DELETE" isn't valid, it's probably falling back on "GET".

However, Laravel has a way around this. Just add a hidden input inside of the form with a name of _method:

<input type="hidden" name="_method" value="delete" />

Let me know how this works!

P.S. It also looks like you're not returning anything in your destroy method. You should be returning a view, or a redirect.

Last updated 8 years ago.
0

the url display http://localhost:8000/products/productsname?_method=delete and still displays 'products.show' route

when i try other method error:

MethodNotAllowedHttpException in RouteCollection.php line 219: in RouteCollection.php line 219 at RouteCollection->methodNotAllowed(array('GET', 'HEAD', 'PUT', 'PATCH', 'DELETE')) in RouteCollection.php line 206 at RouteCollection->getRouteForMethods(object(Request), array('GET', 'HEAD', 'PUT', 'PATCH', 'DELETE')) in RouteCollection.php line 158

Last updated 8 years ago.
0

I'm so fool I should using POST method and it works, now it calls to the right route name. thanks for pointing that out. I'm to focused to the error message

0

Yeah, I should have mentioned that you have to set it to post, my bad.

I'm glad you got it figured out!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

eiyu eiyu Joined 26 Jan 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.