by Devin Yang
(This article was automatically translated.)

Published - 6 years ago ( Updated - 6 years ago )

Why does Laravel need Form Method Spoofing?
Because HTML forms do not support PUT, PATCH and DELETE and other actions, so On Laravel
When submitting the HTML form, we need to send it as an HTTP request through a hidden _method input field.
In this way, Laravel's Restful style routing can know whether the request is PUT or PATCH...etc.

Prior to Laravel 5.5, forms could embed two hidden input fields:
<form action="/foo/bar" method="POST">
    <input type="hidden" name="_method" value="PUT">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
or
<form action="/foo/bar" method="POST">
    {{ method_field('PUT') }}
    {{ csrf_field() }}
</form>
After Laravel 5.6, we can also achieve the same effect through Blade directive:
<form action="/foo/bar" method="POST">
    @method('PUT')
    @csrf
</form>

 

Tags: laravel

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


dlaravel

D-Laravel test domain name *.dev changed to *.test

Since Google Chrome 63 will forcibly convert the domain name of *.dev to https, the domain name of the new version of D-Laravel will be changed to *.test. This article explains how to update.

laravel

Laravel 5.6 has those new changes

Laravel 5.6 is scheduled to be released in February 2018, what changes? Let's see. (Argon2i Password Hashing Algorithm) ​​​​​​​​Argon2 provides the following three versions: 1. In Laravel 5.6, Argon2i password hashing algorithm will be supported. (Argon2i Password Hashing Algorithm) 2. Argon2d resists GPU cracking attacks to the greatest extent. 3. Argon2i is optimized to resist side-channel attacks. Third, Argon2id is a hybrid version. It follows the Argon2i method for the first pass, and then uses the Argon2d method for subsequent passes. It doesn't matter if you don't understand it, I don't understand it anyway, the point is, it's safe to be sure anyway.This is the Open Cryptography Contest (PHC) on July 20, 2015

laravel

Let's run Laravel

If you haven't heard of D-Laravel, let me introduce it. D-Laravel is a Laravel and docker execution environment built with docker-compose. Let us quickly generate Laravel projects through simple bash. This article teaches you how to use the docker image provided by D-Laravel to build a swoole execution development environment. After reading this article, you should be able to quickly create a swoole execution environment through D-Laravel.