TransWikia.com

Remove one of the two "Apply to selected items" submit buttons with Node Bulk Operations

Drupal Answers Asked on December 4, 2021

If you make a view and add the Node operations bulk form, two "Apply to selected items" boxes are automatically generated like this:

two apply to selected items boxes

How do I get rid of one of these?

I turned on twig debugging, but the template that is outputting the button is core/modules/system/templates/container.html.twig, which is not something that I can easily customize to remove one of the buttons.

How I created the view:

  1. Create a new view of content showing fields.
  2. Add Node operations bulk form under Fields.
  3. Save the view.

One Answer

This is intentional functionality for some workflows (for long lists of results).

If you wanted to get rid of the button, you could hook_form_alter it away. Form IDs and array structure are dynamic based on your view so you'll have to adjust accordingly based on the view & action button to remove (this can be found in the Views UI, if not known).

/**
 * Implements hook_form_alter().
 */
function MODULE_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // @TODO: Determine view_id / display_id / field_id for a specific VBO form:
  if ($form_id == 'views_form_' . $view_id . '_' . $display_id) {
    // HEADER ACTION BUTTON:
    //unset($form['header'][$field_id]['actions']);
    // FOOTER ACTION BUTTON:
    //unset($form['actions']['submit']);
  }

Answered by Shawn Conn on December 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP