First of all, great module - thanks for maintaining it!

I have two horizontal tabs named Saturday and Sunday used for adding/editing a node form. In the content type definition, Saturday defaults to open and Sunday defaults to closed. I would like to dynamically close Saturday and open Sunday.

From http://drupal.org/node/1370914, I thought I could use hook_field_group_pre_render_alter like so:

function lcog_bcc_field_group_pre_render_alter(&$element, $group, &$form) {
if ($group->format_type == 'htab') { //only change HTAB item
if ($element['#id']=='node_commute_form_group_saturday') {
$group->format_settings['formatter']='closed';
}
if ($element['#id']=='node_commute_form_group_sunday') {
$group->format_settings['formatter']='open';
}
}
}

but Saturday continued to show up as the open tab.

After dumping $element, $group and $form and looking for all other places where the tab states might be set, I added the following to the Saturday part of the code above:

$element['#collapsed'] = TRUE;
$group->collapsed = TRUE;
$group->classes .= 'collapsed ';
$form['group_commute_days']['group_saturday']['#attributes']['class'][4]='collapsed';

and this to Sunday:

$element['#collapsed'] = FALSE;
$group->collapsed = FALSE;
$group->classes=str_replace('collapsed ', '', $group->classes);
unset($form['group_commute_days']['group_sunday']['#attributes']['class'][3]);

but it did not help - Saturday is still showing as the default tab on the form.

Of course, I've cleared my cache every time. . .

I'm sure I'm just missing something obvious. Any ideas? Thanks so much. . .

Jeff

Comments

oops - sorry, posted in the wrong place..

I am setting #default_tab to the corresonding fieldsets ID in a custom $form array (i.e. '#default_tab' => 'edit-section-pricecategories-wrapper-content-types-2'). However, this setting seems to be ignored.

Did anyone get this working?

the only way that I managed to get that working is by adding

<?php
    
//add inline javascript
    
drupal_add_js('
           window.location = "#'
.$open_tab.'";
     '
, 'inline');
?>

in hook_form_alter, where $opentab is ID of the horizontal tab set in structure -> content type -> manage fields.
Not pretty but it works.