We're updating the issue view to help you get more done. 

HTTP Method Spoofing for Forms

Description

Return the user-desired HTTP method, if given. Otherwise, return the CGI.REQUEST_METHOD, as usual.

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

This will introduce no breaking issues while making it possible for normal forms to follow RESTful routing guidelines.

HTTP Verb

Path

Handler@Action

Used For

GET

/posts

posts@index

Displays a list of all posts

GET

/posts/new

posts@new

Returns an HTML form for creating a new post

POST

/posts

posts@create

Creates a new post

GET

/posts/:id

posts@show

Displays a specific post

GET

/posts/:id/edit

posts@edit

Returns an HTML form for editing a post

PATCH/PUT

/posts/:id

posts@update

Updates a specific post

DELETE

/posts/:id

posts@destroy

Deletes a specific post

1 2 3 4 5 6 7 8 9 10 <form method="POST" action="#event.buildLink( 'posts.#post.getId()#' )#"> <input type="hidden" name="_method" value="DELETE" /> <button type="submit">Delete</button> </form> <!--- Instead of ---> <form method="POST" action="#event.buildLink( 'posts.#post.getId()#.delete' )#"> <button type="submit">Delete</button> </form>

The HTMLHelper has been updated as well:

1 2 3 4 5 6 7 8 9 10 11 // Some comments here #html.startForm( action = "posts.#prc.post.getId()#", method="DELETE" )# #html.submitButton( name = "Delete", class = "btn btn-danger" )# #html.endForm()# <!--- will output ---> <form action="http://localhost/posts/1" method="POST"> <input type="hidden" name="_method" value="DELETE" /> <input type="submit" name="Delete" value="Submit" class="btn btn-danger" id="Delete"/> </form>

Status

Assignee

Eric Peterson

Reporter

Eric Peterson

Labels

None

Components

Fix versions

Priority

Major