It would be great if direct links to a vertical tab fieldgroup were possible. At the moment a link to www.example.com/node/11/edit#group_fieldgroup_name brings you to the edit form but the default vertical tab (tab 1) is always selected. The desired behavior is that the edit form would open with the specified vertical tab selected.

Note: This functionality currently exists in the D6 Vertical Tabs module (see http://drupal.org/node/376293)

Comments

nod_’s picture

Version: 7.9 » 8.x-dev

This needs to be fixed in 8.x first, then backported to 7.x

cluther’s picture

Maybe this needs to be recategorized as a bug or documentation request. Looking through vertical-tabs.js I discovered the following:

...
      if (!tab_focus) {
        // If the current URL has a fragment and one of the tabs contains an
        // element that matches the URL fragment, activate that tab.
        if (window.location.hash && $(window.location.hash, this).length) {
          tab_focus = $(window.location.hash, this).closest('.vertical-tabs-pane');
        }
        else {
          tab_focus = $('> .vertical-tabs-pane:first', this);
        }
      }
      if (tab_focus.length) {
        tab_focus.data('verticalTab').focus();
      }
    });
...

So maybe the feature is already in there and I'm just not using it correctly. But I could not find any specific documentation. So far I've tried calling using the fieldgroup name, and the human readable name. I looked for a specific CSS ID, but none existed.

Regards,

Chris

nielsvoo’s picture

Hello Cluther,

I figured it out, sometimes the things you are looking for are actually quite simple. When i opened the source of the page containing the vertical tabs i noticed that the tab has an ID generated by Drupal 7, this is the one needed to point to your favorite tab.

For example your tab group name is group_mytab then your link should be:
http://www.yourdomain.com/yourpage/edit#edit-group_mytab

I hope it will work for you too...

Niels

jpstrikesback’s picture

Status: Active » Closed (works as designed)

Just to update the ticket, the above works, the fieldsets are the elements which contains the IDs to target. Thanks Nielsvoo!!

earwax’s picture

Just to update, the above above does *not* work for horizontal tab groups.

... the fieldsets are the elements which contains the IDs to target.

This is true for horizontal tab items, as well, but creating a link to it goes back to the original problem of just linking to the default horizontal tab item (#1). If you want to go to horizontal tab item #2 or #4, then you are S.O.L

Maybe this works for vertical tabs, but it does not work for horizontal tab groups and items. Maybe they will fix this in Drupal 11.0

rmathew’s picture

Issue summary: View changes
Status: Closed (works as designed) » Needs work

I don't believe this should have been closed. Cluther already pointed out that you can link directly to a vertical tab group in the initial issue report. The problem is that the first vertical tab is always selected.

As cluther said, www.example.com/node/11/edit#group_fieldgroup_name already works - but we want www.example.com/node/11/edit#group_vertical_tab_name

PlayfulWolf’s picture

The original problem still persists and #3 trick does not solve that for me for vertical tabs. I am using Fieldgroup module, so this may be the case, but horizontal tabs are working great.

anou’s picture

Hello,
I'm using vertical tabs in D7 in a custom admin form.
I've manage to get the right tab to be opened onload with the ID of the corresponding fieldset.

e.g.: http://mydomain.com#ID_of_the_FIELDSET_of_my_desired_TAB_to_be_openned

LDG27182’s picture

I'm not sure if everyone has gotten horizontal tabs inside of tab groups to work, so I am posting here in case it helps.

I am able to open a form directly to any horizontal tab, even one inside of a tab group, using the anchor #tab-id on the end of the edit url. To make it work, I first had to manually set a tab id for each tab, in the content type settings at :
http:///admin/structure/types/manage/

On that settings page, click the gear that is on the same line as the tab. Here, you should see an "id" field that is blank. Enter a unique id such as "my-tab-id", and then save the content type settings form.

After doing this, I could go directly to a horizontal tab that was part of a group, just by adding #my-tab-id to the end of the node edit url.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Elijah Lynn’s picture

I am experiencing that the group name does work but since it targets the fieldset and not neccesarily the vertical tab then the vertical tab doesn't show it is selected.

However, if I use the label name of the vertical tab with the + sign instead of spaces or spaces then it does link to the vertical tab.

#edit-group_images (with a label of 'Party Pics') (links to the fieldset, no vertical tab selected
#Party+Pics (links to the vertical tab, vertical tab is selected)
#Party Pics (links to the vertical tab, vertical tab is selected)

However, if I don't use the correct case it doesn't work.
#Party pics (does not work)

The problem with the latter is that when there is an Ajax callback for a "add another/more" button. When it returns it jumps to the current window.location that is set. It doesn't appear to do this with the former example with the fieldset group name but again the disadvantage is that it doesn't show the vertical tab as selected, which is a UX disadvantage.

Elijah Lynn’s picture

Elijah Lynn’s picture

There is a patch in #376293: Activate current vertical tab from URL fragment for Drupal 7 that updates the window.location (URL bar) with the vertical tab hash.

Update: actually, it is #2752511: Update location.hash when clicking a vertical tab.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.