--- vertical_tabs.js.old 2009-10-27 19:06:39.000000000 -0500 +++ vertical_tabs.js 2009-10-27 19:05:50.000000000 -0500 @@ -51,11 +51,32 @@ Drupal.behaviors.verticalTabs = function $('div.vertical-tabs').html(ul).append(panes); - // Activate the first tab. + // Check vertical tab panes for required fields and indicate them on the + // corresponding vertical tab button. + $('fieldset.vertical-tabs-pane').each(function(i){ + if ($(this).find('.form-required').length > 0) { + $('li.vertical-tab-button').eq(i).children('a').prepend($('.form-required').eq(0).clone()); + } + }); + + // Activate a tab if it contains a validation error. $('fieldset.vertical-tabs-pane').hide(); - $('fieldset.vertical-tabs-pane:first').show(); - $('div.vertical-tabs ul li:first').addClass('first selected'); - $('div.vertical-tabs ul li:last').addClass('last'); + $('li.vertical-tab-button:first').addClass('first'); + $('li.vertical-tab-button:last').addClass('last'); + $('fieldset.vertical-tabs-pane').each(function(i){ + if ($(this).find('.error').length > 0) { + $(this).show(); + $('li.vertical-tab-button').eq(i).addClass('selected'); + return false; + } + return true; + }); + + // Otherwise, activate the first tab. + if (!$('li.vertical-tab-button').hasClass('selected')) { + $('fieldset.vertical-tabs-pane:first').show(); + $('li.vertical-tab-button:first').addClass('selected'); + } } }