Active
Project:
Webform Conditional (Same Page Conditionals)
Version:
6.x-1.0-rc2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
12 Jul 2011 at 05:57 UTC
Updated:
21 Dec 2012 at 05:07 UTC
Using cck_blocks module breaks webform conditionals because of js being included twice. This is happening because of an issue in cck_blocks (#833730: Cck block display settings override basic node settings.). May be webform_conditional_add_js() should be protected against multiple inclusion like this:
function webform_conditional_add_js(&$form, $form_state) {
static $js_added;
if (!isset($js_added)) {
drupal_add_js(array('webform_conditional' => $form['#webform_conditional_js']), "setting");
drupal_add_js(drupal_get_path('module', 'webform_conditional') . '/webform_conditional.js');
$js_added = TRUE;
}
return $form;
}
(patch included)
Perhaps it would be worth waiting until the issue with cck_blocks was resolved. But since there is such a simple (and widely used) way to avoid similar problems in the future, why not use it?
| Comment | File | Size | Author |
|---|---|---|---|
| webform_conditional_js_fix.patch | 941 bytes | dan.nsk |
Comments
Comment #1
tedbow@ dan.nsk , thanks for the patch but just wondering...
If the goal of the patch is to be able to have 2 Webforms that use this module shown on one page I am not sure it will work.
The patch will stop the javascript from being add twice. I don't think the 2 webforms would actually work.
any ideas?
Comment #2
dan.nsk commentedNo, in my case even a single webform stops working because of the issue mentioned above. The problem is definitely with cck_blocks, but when the issue is resolved (and backported to 6.x), who will guarantee that another bug will not break webform conditionals again.
Comment #3
thsutton commentedI've just created #1484932: Conditional fields are not shown in webform displayed in blocks which also results in broken Javascript, there due to changes IDs when a webform is displayed in a block.
Perhaps the approach to generating and including JS needs to be revised? Making `Drupal.settings.webform_conditional` a hash would more readily support multiple forms on the same page (multiple copies of the same form even, as in my issue):
Comment #4
DaPooch commentedDid the 6x version of the cck_blocks issue ever get back ported? I can verify that the above patch works for me, but I'd like to get cck_blocks running right too. I can't seem to tell if it was ever resolved for 6x.