xp-forge / frontend

Web frontends
1 stars 1 forks source link

Add support for special `_method` field to overwrite POST for routing #42

Closed thekid closed 10 months ago

thekid commented 10 months ago

HTML forms do not support anything other than GET and POST. The value sent with the _method field will be used as the HTTP request method instead of POST:

<form action="/example" method="POST">
  <input type="hidden" name="_method" value="PUT">
  <!-- Rest of form -->
</form>

This will use PUT for the server-side routing instead of POST. The method inside the request object will stay the same, though.

The name was chosen as it is a pseudo-standard amongst various frameworks.


See also:

thekid commented 10 months ago

Released in https://github.com/xp-forge/frontend/releases/tag/v5.4.0