Change order of separate action buttons

Created on 23 October 2019, about 5 years ago
Updated 17 August 2023, about 1 year ago

Duplicate of Allow sorting of actions Needs work

When displaying selectable actions as buttons there is no way to sort or order the actions via the UI.

This can be achieved with a simple form_alter, posting here in case anyone else needs it:

function MYMODULE_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
    switch ($form_id) {
        case 'MY_VBO_VIEW_FORM_ID':
            
            $form['actions']['views_bulk_operations_delete_entity']['#weight'] = 0;
            $form['header']['views_bulk_operations_bulk_form']['actions']['views_bulk_operations_delete_entity']['#weight'] = 0;

            $form['actions']['MY_CUSTOM_ACTION']['#weight'] = 1;
            $form['header']['views_bulk_operations_bulk_form']['actions']['MY_CUSTOM_ACTION']['#weight'] = 1;
            
            break;
    }
}

It was necessary to target both the main actions and the header actions to apply the changes to both sets of buttons above and below the view table.

Feature request
Status

Closed: duplicate

Version

3.0

Component

User interface

Created by

🇬🇧United Kingdom david.qdoscc

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.71.5 2024