By John Koster
method_field($method)
The method_field
helper function is a simple function that returns a new instance of Illuminate\Support\HtmlString
. The contents of the HtmlString
instance is a hidden HTML input
field with the name _method
and the a value of $method
.
The following example highlights the results of the method_field
function:
1<?php
2
3method_field('PUT');
4method_field('POST');
5method_field('GET');
6method_field('PATCH');
7method_field('DELETE');
The return value of the method_field
function is an instance of HtmlString
. The corresponding HTML string value for each function call above would be:
1<input type="hidden" name="_method" value="PUT">
2<input type="hidden" name="_method" value="POST">
3<input type="hidden" name="_method" value="GET">
4<input type="hidden" name="_method" value="PATCH">
5<input type="hidden" name="_method" value="DELETE">
∎