EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Can't render Delete button as button

Open mhbailly opened this issue 2 months ago • 2 comments

Describe the bug

  • On the Detail page, I want all the actions to look like buttons
  • By default, the Delete action is now a link (corresponding change )
  • In the controllers, the Action cannot be configured to be displayed as a button

To Reproduce In a Controller try the following

public function configureActions(Actions $actions): Actions
{
  $actions = parent::configureActions($actions);
  $actions->update(Crud::PAGE_DETAIL, Action::DELETE, static function(Action $action) {
                return $action
                    ->renderAsButton()
                    ->asTextLink(false);
  });
  return $actions;
}

Additional context

  • asTextLink(false) does nothing
  • renderAsButton() does not change the style

mhbailly avatar Oct 08 '25 22:10 mhbailly

Image

The "Delete" button comes with a class named btn-invisible. It appears to originate from /template/crud/action.html.twig @ line 7: isInvisible="{{ action.usesTextStyle }}"

xenatis avatar Nov 17 '25 16:11 xenatis

I have the same problem on the index page:

Image

In EasyCorp\Bundle\EasyAdminBundle\Config\Actions::createBuiltInAction() (around line 195):

        if (Action::DELETE === $actionName) {
            return Action::new(Action::DELETE, t('action.delete', domain: 'EasyAdminBundle'), 'internal:delete')
                ->linkToCrudAction(Action::DELETE)
                ->asDangerAction()
                ->asTextLink()
            ;
        }

The call to ->asTextLink() marks the delete action as a text link.
There is no way to revert this, because asTextLink() only sets the style to ButtonStyle::Text and doesn’t allow disabling: In EasyCorp\Bundle\EasyAdminBundle\Config\Action

    public function asTextLink(bool $asTextLink = true): self
    {
        if ($asTextLink) {
            $this->dto->setStyle(ButtonStyle::Text);
        }

        return $this;
    }

Is there a reason why delete actions are now forced to be text links?

The change was made in https://github.com/EasyCorp/EasyAdminBundle/commit/64a0cfc9a362860e8e37e65ae535a5dae7ce04db In this commit the docs say: // by default, actions are rendered as solid buttons

And in createBuiltInAction() I found:

if (Action::NEW === $actionName) {
            return Action::new(Action::NEW, t('action.new', domain: 'EasyAdminBundle'), null)
                ...
                ->renderAsLink() // for BC reasons; it's OK because this is a GET action

Maybe the delete action was intended to also use ->renderAsLink() instead of ->asTextLink() @javiereguiluz?

bt-nn avatar Nov 25 '25 13:11 bt-nn