Unable to customize DELETE action URL
In the CrudController configureActions() method, if I write this:
$actions->update(Crud::PAGE_INDEX, Action::DELETE, function (Action $action) {
return $action
->linkToUrl(fn ($entity) => ...anything here...)
;
})
The updated url is correctly displayed on the "Delete" action link, but if you click the button, the delete form POSTs to a fixed url, specified in the "formaction" attribute of the action link.
The problem probably originates here, in ActionFactory.php method processAction():
if (Action::DELETE === $actionDto->getName()) {
$actionDto->addHtmlAttributes([
'formaction' => $this->adminUrlGenerator->setController($adminContext->getCrud()->getControllerFqcn())->setAction(Action::DELETE)->setEntityId($entityDto->getPrimaryKeyValue())->generateUrl(),
'data-bs-toggle' => 'modal',
'data-bs-target' => '#modal-delete',
]);
}
Maybe the "formaction" attribute should take the action url?
@nevez thanks for reporting this error. I think you are right about the cause of the problem. Can you please submit a pull request against 4.x branch to fix it? Thanks!
i think the addCssClass method is not working either
i.e.
.addCssClass('btn btn-primary')