Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jodyHamilton/d0ecea3f2194429bc6b444fc56fcbccd to your computer and use it in GitHub Desktop.
Save jodyHamilton/d0ecea3f2194429bc6b444fc56fcbccd to your computer and use it in GitHub Desktop.
Drupal 8 inline_form_errors with field_group
// Inline_form_errors module gives links to elements with errors.
// When using field_group module (this is for vertical tabs) you need to first open the right vertical tab
// and then scroll to the element with the error.
$('.messages__list a', context).on('click', function(e) {
var url = $(this).attr('href');
var hash = url.substring(url.indexOf('#'));
var index = $(hash).parents('.vertical-tabs__pane').index() - 1;
if (index >= 0) {
$('ul.vertical-tabs__menu li').eq(index).find('a').click();
}
$('html, body').animate({
scrollTop: $(hash).parent().offset().top-150
}, 500);
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment