How in symfony EasyAdmin (https://symfony.com/bundles/EasyAdminBundle/current/index.html) can I create a crud link to delete action for another entity (different crud controller) ?
This is the code that I need to change the entity:
$deleteParticipantsAction = Action::new(
TrainingParticipantCrud::DELETE_ACTION
)
->setLabel("Delete Custom")
->linkToCrudAction(
Action::Delete
);
I tried the following code, but unfortunately when you click on the link symfony does not delete record (not start a dialogbox asking if you want to delete the record), but redirects to the home page.
$deleteOrder = Action::new(
TrainingParticipantCrud::DELETE_ORDER,
"Delete Custom"
)->linkToUrl(function (TrainingParticipant $d) {
return $this->adminUrlGenerator
->unsetAll()
->setAction(Action::DELETE)
->setController(TrainingOrderCrudController::class)
->setEntityId($d->getTrainingOrder()->getId())
->generateUrl();
});