I have a view that looks like in the following screenshot.


I am creating a custom action to publish selected comments and create a node for each comment. The custom action code is the following.

class publishtraction extends ViewsBulkOperationsActionBase {
  use StringTranslationTrait;

   * {@inheritdoc}
  public function execute($entity = NULL, $view = NULL) {
    // Publish the selected comment.
    // Create a node for the selected comment.
    // Don't return anything for a default completion message; otherwise return translatable markup.
    return $this->t('Some result');

   * {@inheritdoc}
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    if ($object->getEntityType() === 'node') {
      $access = $object->access('update', $account, TRUE)
        ->andIf($object->status->access('edit', $account, TRUE));
      return $return_as_object ? $access : $access->isAllowed();

    // Other entity types may have different access methods and properties.
    return TRUE;


My custom action is publishing/unpublishing the comments correctly. However, as next step, I want to read the multiselect field and the selected view row entities values to show them with var_dump().

How can I achieve that?

  • Is your goal to display the row entities without a full page refresh - i.e. via some ajax method? Jul 4, 2021 at 9:49
  • My goal is to publish the selected items and create a node on the selected content type. I want that to happen at the same action. Without a page refresh would work.
    – Jiah
    Jul 4, 2021 at 12:07


Your Answer

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

Browse other questions tagged or ask your own question.