Webform changed how fieldset.inc's webform_fieldset_prerender() function sets the fieldset's ID: It now uses drupal_html_id() on the ID, causing Webform Conditional to no longer hide conditional fieldsets.

The introduced bug is in Webform Conditional's _webform_conditional_get_css_id() function, which now incorrectly computes the value of the fieldset's ID attribute.

The fix is to emulate drupal_html_id()'s behavior when determining the $css_id for fieldsets (and not any other component type; Webform currently only uses drupal_html_id() for fieldset IDs). Webform Conditional cannot call drupal_html_id() on the calculated $css_id, because drupal_html_id() has a counter and will increment the ID when Webform's functions call it again on the same candidate ID.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jay.dansand’s picture

Here is a quick patch (tested lightly; "it works for me" right now) that tries to predict the $css_id by emulating drupal_html_id(). It is brittle if drupal_html_id()'s implementation changes.

green_eye55’s picture

Worked for me too! Thanks.

budda’s picture

Status: Active » Reviewed & tested by the community

This patch fixed my issue too.
Reason was what I suspected, glad somebody has already written the patch :-)

Can we get the patch committed to the dev branch ?

Daniel Wentsch’s picture

Yay, thanks for the patch, fixed the issue for me, too.

sgardapee’s picture

We tried the patch, it does not help. For those that say it worked, what version of webform_conditional and webform are you using. This issue began when we upgraded from 7.x-1.0-beta1 to 7.x-1.0-beta2. At the same time we upgraded webform version 7.x-3.18 to 7.x-3.20. Did it work for existing forms, or newly created forms after the upgrade.

Daniel Wentsch’s picture

Webform 7.x-3.20
Webform Conditional 7.x-1.0-beta2

After Updating Webform to 7.x-3.20 the webform conditonals stopped working correctly (showing fieldsets when they should have been invisible).

Existing forms worked correctly again after patching.

Haven't created new ones since.

sgardapee’s picture

Thanks so much for the info. I determined that the patch was not getting applied correctly. I misspelled it in my makefile. Once it was corrected, the form worked great!

jay.dansand’s picture

Status: Reviewed & tested by the community » Closed (works as designed)

Update: This patch is no longer necessary in Webform 7.x-3.21 and higher. As of 7.x-3.21, drupal_html_id() is no longer used in webform_fieldset_prerender(). For more information, see #2243483: Change in Fieldset id generation.

gregoryshearer’s picture

It appears if you upgrade Webform after Webform Conditional is patched, the patch causes the same symptoms as it once fixed. I needed to reverse the patch to get my conditionals to work on fieldsets.

jay.dansand’s picture

Correct: the patch fixed the Webform 7.x-3.20 issue by making Webform Conditional emulate drupal_html_id() when calculating fieldset IDs (so the calculated IDs matched Webform's IDs again). As of Webform 7.x-3.21, drupal_html_id() is no longer used, so the calculated IDs no longer line up with the HTML that Webform is generating.