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
Comment #1
prinds CreditAttribution: prinds commentedoops - sorry, posted in the wrong place..
Comment #2
haggins CreditAttribution: haggins commentedI 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?
Comment #3
sylwester CreditAttribution: sylwester commentedthe only way that I managed to get that working is by adding
in hook_form_alter, where
$opentab
is ID of the horizontal tab set in structure -> content type -> manage fields.Not pretty but it works.
Comment #4
fabioneves CreditAttribution: fabioneves commentedAnyone managed to do this? I also want to set a tab dynamically.
Comment #5
rimu CreditAttribution: rimu commentedSimilar to #3, I got this working by setting an ID for the tab and then just had # in the URL of the page. e.g. node/20998/edit#group-signoff.
At first it wasn't working but clearing the cache seemed to be the final piece of the puzzle.
NB the ID I set had an underscore in it, but I needed to link to a version of the ID with a dash instead. OK, Whatever :)
Comment #6
e.bogatyrevHi there,
I faced with the same trouble but with vertical tabs. I think the solution should be work for horizontal tab as well, but didn't check.
To make the some tab is active by default we should implement the hook hook_field_group_build_pre_render_alter() and set the #value (should be an identifier of needed fieldset) for *__active_tab. Here an example
Comment #7
tjerah CreditAttribution: tjerah commented