I'm experiencing an issue that I think I've narrowed down to a particular set of circumstances (tested on a couple of different instances with other webform related modules disabled) - this is using webform_accordion-7.x-2.0-alpha1 with webform-7.x-4.0-rc3.
How to reproduce:
Create a web form, and in the 'Advanced Settings' section of 'Form Settings', check Show "Save Draft" Button.
Create an accordion container with a couple of accordion tabs.
In each tab, create one or more required fields.
Now, while viewing the web form, leave at least one of the required fields empty and click 'Save Draft'. The page refreshes and the accordions display as expected.
Now, leave at least one of the required fields empty and click 'Submit'. The page refreshes and returns a validation error as expected, but the the Drupal.settings.webform_accordion javascript object is not defined and the accordion group does not activate; the accordion divs are all there but not the jQuery accordion API 'activate' method doesn't seem to be firing.
If you then open up a brower javascript console and type:
jQuery('.accordion-container').accordion({activate: function(event, ui){}});
The accordion tabs will pop into place... so there seems to be something going on with how the form is rendered after saving a draft and then submitting with validation errors; some form building/rendering step skipped? This is a bit of a roadblock for my purposes so I'll be continuing to troubleshoot this - but if anyone else has any ideas or insights they'd be much appreciated.
Comments
Comment #1
usonian commentedA little more specifically: it seems that the crux of the issue is that
_webform_render_accordion_grp()does not get called if the form reloads with validation errors, and thus theDrupal.settings.webform_accordionobject never gets populated.Maybe someone with a more intimate working knowledge of the interplay between the native FAPI and the Webform API can accomplish this more elegantly, but for the time being I came up a workaround in a custom module I was already using for the project:
$form['#validate']which adds a "forceActivateAccordion" flag to theDrupal.settings.mymodulenamejavascript object.$(window).load()function of the module'sDrupal.behaviors.mymodulenameBehaviorobject, I check to see if 'forceActivateAccordion' is set; if so explicitly trigger activation of the accordion there.