EasyAdmin 3 delete link

1.2k views Asked by At

I use EasyAdmin to manage product and product prices CRUD.

screenshot of my product details with product prices list

I customized my productDetail page, in order to display productPrices in addition of the product details entity. So I display product informations, and a list of product prices, stored in another entity. In order to manage this list, I created some custom easyAdmin urls like this :

{% set url2 = ea_url()
.setController('App\\Controller\\Admin\\ProductPriceCrudController')
.setAction('edit')
.setEntityId( price.id) %}

or

{% set url3 = ea_url()
.setController('App\\Controller\\Admin\\ProductPriceCrudController')
.setAction('delete')
.setEntityId( price.id) %}

Or, this second link does not operate. I am redirected to my crud index page, and my entity is not deleted.

Do you know how to configure my 'delete' link in this case ?

Thanks for your help !

1

There are 1 answers

0
Harold On

To delete entity you need to post form (with ea token):

<form action="{{ ea_url().setController('App\\Controller\\Admin\\ProductCrudController')
    .setAction('delete')
    .setEntityId(product.id) }}" method="post">

    <input type="hidden" name="token" value="{{ csrf_token('ea-delete') }}" />
    <button type="submit" class="btn btn-danger btn-sm" >
        <i class="fas fa-trash"></i>
    </button>
</form>