3

Using VBO, I am trying to set the Operations Fieldset to collapsed by default. Is there a setting to do this? or a theme override that I can use per view?

enter image description here

7
+50

Use hook_views_bulk_operations_form_alter()

<?php
function mymodule_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) {

 if($form['#form_id'] =='views_form_block_id'){

  $form['operations_fieldset']['#collapsed'] = TRUE;

 }

}
?>
1
  • 2
    You deserve the bounty for taking the time to give him the proper form ID, the more efficient function call, and the fieldset element's ID :) Feb 21 '13 at 17:13
2

You can do this in a hook_form_alter():

<?php
mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_bulk_operations') { // inspect your form in your browser to get the actual ID; it's in a hidden element at the bottom of the form.
    $form['operations_fieldset']['#collapsed'] = TRUE;
  }
}
?>

This assumes the fieldset's name is "operations_fieldset". You should install the devel module (drupal.org/project/devel) and then do a dpm($form) inside the if() statement in the code above to see what the form's elements are named.

More info on the 'fieldset' form element: http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#fieldset

1

I had to use this to get this to work in 7.x-3.2

<?php
function mymodule_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) {
  if($form['#form_id'] =='views_form_[view_machine_name]_[view_display_type]'){
    $form['select']['#collapsible'] = TRUE;
    $form['select']['#collapsed'] = TRUE;
  }
}
?>

If you want it to apply to all bulk operations forms then just remove the $form['form_id'] condition.

0

For all who googled this with a similar question: We have an issue to change the fieldset to *un*collapsible in VBO which might need some help.

Until we have that i rolled a sandbox module for this, based on Ryan G's snippet, but incorporating the API changes which happened since then.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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