If you are not using the form module (without the vertical_tabs_forms registry) and you need to configure the vertical tabs settings just with code in a custom module, there is no way to do it with
fieldsets that doesn't have the #config defined in its $form['fieldset_name'].

So now the default option where you had any new fieldset added in vertical_tabs (and you just needed to defined the excluded ones) doesn't work.

For example with xmlsitemap, print, notifications, custom breadcrumbs the fieldset added doesn't have any #group property so it's not shown in the vertical tabs by default.

You can see it if you add some of this modules, and the fieldsets are not added by default, if you use the form module, you will see that this fieldsets are off.

If you removed this lines in vertical_tabs_add_vertical_tabs():
// Skip any non-grouped elements.
if (empty($element['#group'])) {
continue;
}
Everything works fine again. (you have to manually override or exclude any fieldset that you don't want to have in vertical_tabs).

You told that you added that feature because the D7, but probably in D6 is not needed (the form API at least doesn't add this as we can see in existing modules)

Comments

dave reid’s picture

This is the same way the D7 core vertical tabs work so this is how the backport should work by default. Instead, let's file issues for modules that add a fieldset to do this correctly, and its one less thing they need to worry about when porting their modules to D7.

dave reid’s picture

Latest XML sitemap (6.x-2.x) is already fixed.
Nodewords is already fixed.
Issue for scheduler already filed.

Use the 'vertical tabs' issue tag so we can keep track of them.

jcmarco’s picture

Would it be possible to have some hook alter or something similar to add general settings to form fieldsets?

This way, it would be possible to change settings to fieldsets as #group to add it into vertical tabs, change weight, or title, or even add #attached to add any js or css to theme the tabs configuration.

It would allow customize the vertical tabs configuration for any module from a custom module.

Doing this change in a hook_form_alter is painful as it needs to be done on any node_form or node_type_form, and search for any fieldset in the form.

Now it is possible to active vertical tabs in system forms or custom forms using $form['#pre_render'][] = 'vertical_tabs_form_pre_render'; but it is mandatory to
add the #group option in existing fieldsets to have it working with vertical tabs.
If you are developing a module you can add it for yourself but there is no way to do it in external modules without hacking it.

Just adding drupal_alter('vertical_tabs', $elements); before the return $elements; in vertical_tabs_get_form_elements(), you can have a function like:

function mymodule_vertical_tabs_alter(&$elements) {
  if (isset($elements['print'])) {
    $elements['print']['#group'] = 'additional settings';
    $elements['print']['#title'] = 'Print, e-mail and PDF';
    $elements['print']['#weight'] = 30;
  }
}

Is there any other way?

dave reid’s picture

You can accomplish the exact same thing with using hook_form_alter().

Issues filed for print, signup, and page_title.

davemybes’s picture

StatusFileSize
new1.72 KB

I think having a general "Use vertical tabs" by default on/off switch would be great, so that we wouldn't have to patch tons of different modules, or write hook_form_alters for each module we use. To this end, I modified VT and got it all working nicely. Here is the patch against the current dev version.

Basically, it adds in a settings page, with a new permission, and modifies the "Skip any non-grouped elements." check to check this new setting.

jcmarco’s picture

I think that be dependent on all module developers to make this change could take time.
Some temporal solution to make compatible any existing module with the vertical tabs would be nice.
(I have understood that in D7 the core integrated vertical tabs feature will remove this issue, but in D6 vertical tabs is optional)

#incrn8 patch is other nice way

While we can find some easy way to make vertical tabs work everywhere, I will start opening issues (with the vertical tabs tag) in modules that I find need this #group property.

The form alter solution has an inconvenient, I found modules that are at a different execution level that my custom module and they don't take the
alter modifications unless I increase my module execution level.

Probably some instructions about methods to customize vertical tabs could go in the INSTALL.txt, or for module developers how to make his module vertical tab compatible (adding the #group property and even an js sample to customize the tab content)

The different methods I found are:
- form module (but is heavy lift module for production servers)
- custom hook_form_alter
- import a 'vertical_tabs_forms' variable (from a previous form module configuration)
- adding #group property in modules fieldsets
- any other?

I am very happy with this module I would like to use it intensively everywhere.

dave reid’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.