dollar dollar - 1 year ago 150
HTML Question

How to use form element in Laravel 5.2 without using form facade?

As I am new to laravel framework, I have a query, I am using tag in blade template so that I can delete the data from table.

I am using this the below code of form tag to delete the data

<form action="{{ route('admin.states.update',$data->state_id) }}" id="form_sample_2" class="form-horizontal" novalidate="novalidate" method="PUT">

Here I have used method as PUT, but browser is automatically considering it as GET request, I found some questions on stackoverflow where many of them said PUT & DELETE is not detected by browser.

So using Laravel Facade Form , this problem is solved

{!! Form::open(array('route'=>['admin.states.update',$data->state_id],'role'=>'form','method'=>'PUT')) !!}

The above code work as intended but my query is I don't want to use Formfacade in Laravel , I want to use first type of HTML code for form opening.

Is there any other method by which I can use PUT method in HTML Form Tag without using any Form FAcade in Laravel.

Answer Source

set form method to post and add a hidden input as following

<input type="hidden" name="_method" value="put">

and also make sure to add

<input type="hidden" name="_token" value="{{ csrf_token() }}">

If your ValidateCSRF middleware is enabled.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download