Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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);
Comment | File | Size | Author |
---|---|---|---|
#5 | field_group-pass-current-tab-state-to-form-action-1815784-5.patch | 896 bytes | sokru |
#1 | field_group-preserve-tab-state-1815784.patch | 824 bytes | omegared |
Comments
Comment #1
omegared CreditAttribution: omegared commentedhere is the patch
Comment #2
rolando.alevelbeyond CreditAttribution: rolando.alevelbeyond commentedJust 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.
Comment #3
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedComment #5
sokru CreditAttribution: sokru at Druid commentedJust reroll to current dev.