I had a user profile form with many tabs and sub tabs. The client was frustrated that upon saving the form the page refreshed and started on the default tab. In order to keep the tab they were working on open I added some jQuery to the field_group/horizontal-tabs/horizontal-tabs.js file. This is my first patch so please let me know if there is anything more I can do.

Known issues:
The jQuery runs in the view mode and edit mode. This should be fixed since there is no form on the view mode.

This is the jQuery added to the focus function of horizontal-tabs.js:

//append the tab anchor to the action of the form to preserve state
  formaction = $('form').attr('action');
  var hashind = formaction.indexOf("#");
  var newaction = formaction.substring(0,hashind)+"#"+$(this.fieldset).attr('id');
  $('form').attr('action',newaction); 
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

omegared’s picture

here is the patch

rolando.alevelbeyond’s picture

Just tried this out and it works great.. i just added a little more js to make the page scroll to top instead of displaying where the anchor is just so it's easier for the client and doesn't scroll down to the top of the horizontal group.

SocialNicheGuru’s picture

Issue summary: View changes
Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: field_group-preserve-tab-state-1815784.patch, failed testing.

sokru’s picture

Just reroll to current dev.