How can one add a field in views with a link to a custom Action plugin?

With bulk operations it's possible to create a checkbox to perform an action to a set of results. My actions have an access check that may be different per result so using the checkbox would result in a lot of warnings when the user tries to perform the action and doesn't have access.

I'd prefer to show the action as a link and only show the link when the user has access.

1 Answer 1


I'm thinking about setting up a route with a csrf token and an access check on a controller that manually performs the action:

  path: '/node/{node}/my_action_callback'
    _controller: '\Drupal\my_module\Controller\ActionController::my_action'
    _title: 'My action'
    _permission: 'perform my action'
    _csrf_token: 'TRUE'
    _custom_access: '\Drupal\my_module\Controller\ActionController::my_action_access'

In ActionController::my_action I could perform the action programmatically:


I had hoped there was a less complex and more elegant way using an existing view plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.