HTML DELETE method on one button
You can create a shape around the delete button. This will not add anything visually to the page.
For example:
{{ Form::open(['url' => 'foo/bar', 'method' => 'delete', 'class' => 'deleteForm']) }}
<input type="submit" class="deleteBtn" />
{{ Form::close() }}
Laravel's form helper automatically tricks the form and adds a hidden field for the method DELETE
.
Then you can style the button using the class .deleteBtn
. If the button needs to be placed on a row, you can even assign a display: inline;
class to the property .deleteForm
.
source to share
You can add a form and use Laravel Ways to Create Forms
<input type="hidden" name="_method" value="DELETE">
or you can use ajax (example code below uses jQuery)
$.ajax({
url: 'YOUR_URL',
type: 'DELETE',
success: function(result) {
// Do something with the result
}
});
source to share
You can also use this library https://gist.github.com/soufianeEL/3f8483f0f3dc9e3ec5d9 to implement this:
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}" data-confirm="Are you sure?">
source to share