Sandeep Yadav
Sandeep Yadav

Reputation: 587

How to add delete confirmation in laraadmin modules?

I am using laraadmin in one of my application but module generated by admin not confirming when deleting any record. Please some one help me How to add delete confirmation in laraadmin modules?

Upvotes: 0

Views: 273

Answers (1)

Adam Kozlowski
Adam Kozlowski

Reputation: 5896

I do not know how to work with laraadmin but You can do that by java script:

Blade:

@foreach (items as item)
    <form class="delete" action="{{ route('item.destroy', $item->id) }}" method="POST">
        <input type="hidden" name="_method" value="DELETE">
        <input type="hidden" name="_token" value="{{ csrf_token() }}" />
        <input type="submit" value="Delete">
    </form>
@endforeach

JS:

<script>
    $(".delete").on("submit", function(){
        return confirm("Do you want to delete this item?");
    });
</script>

And if you need preety nice confirmation design You can use Sweet Alert JS Library: https://sweetalert.js.org/guides/

Upvotes: 1

Related Questions