Allow bulk actions to return a status message

Created on 26 July 2020, almost 4 years ago
Updated 22 April 2024, about 2 months ago

Problem/Motivation

After a bulk action is carried out, the status message '%action was applied to @count items.' is displayed. However, this will be misleading if an error occurred during the action, and fewer (maybe zero) items were successfully processed. The action code may, of course, display its own message(s) to indicate when an error has occurred, but there is then potential for confusion, with contradictory messages shown - one indicating success, another indicating failure.

It can be seen from the definition of \Drupal\Core\Action\ActionBase that a return value is not provided, and correspondingly, the code in modules/contrib/entity/src/BulkFormEntityListBuilder.php and in core/modules/views/src/Plugin/views/field/BulkForm.php calls $action->execute($entities) without looking for a return value.

Proposed resolution

The Views Bulk Operations β†’ module provides similar functionality, and this allows an action to provide a return value. If no value is returned, then a default message is displayed, otherwise the returned value is displayed as the completion message. I propose the same approach in the core Action module.

Remaining tasks

Port the relevant code over from VBO.
Test.

User interface changes

tbc

API changes

tbc

Data model changes

None.

Release notes snippet

n/a

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component
SystemΒ  β†’

Last updated 2 days ago

No maintainer
Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024