When multiple conditionnal forms are printed on the same page, only the first one works.
I think I traced it to this function :
Drupal.webform_conditional.getComponentsByName = function (field_name){
// check to save jquery calls
if(Drupal.webform_conditional.components[field_name]){
return Drupal.webform_conditional.components[field_name];
}
// don't overwrite original name to store for caching
var css_field_name = "[" + field_name + "]";
var nid = Drupal.settings.webform_conditional.nid;
if(nid instanceof Array){
nid = Drupal.settings.webform_conditional.nid[0];
}
return Drupal.webform_conditional.components[field_name] = $("#webform-client-form-" + nid + " *[name*='"+css_field_name+"']");
};
More specifically :
var nid = Drupal.settings.webform_conditional.nid;
if(nid instanceof Array){
nid = Drupal.settings.webform_conditional.nid[0];
}
return Drupal.webform_conditional.components[field_name] = $("#webform-client-form-" + nid + " *[name*='"+css_field_name+"']");
If I understand well, when there are several forms on the same page, there is a problem because for every fields, you take the first form to build the identifier ( $("#webform-client-form-" + nid + " *[name*='"+css_field_name+"']")
Wouldn't be better to use the parent ?
Comments
Comment #1
davidpetit commentedHi Seb ! I agree we should find directly the ID of the parent form with jQuery parents() starting from the field current item.
So I propose this patch.
Comment #2
davidpetit commentedComment #3
tedbow@DavidPetit thanks for catching this. I think your patch will only work though if 2 webforms on the same page don't have any component that have the same key. If they have the same key if it still might not get the right one.
Comment #4
davidpetit commented@tedbow
I can't see what you mean; because since the form_id is unique, even if the key is the same, we will have:
"#form_id_nid_1 field_name" and "#form_id_nid_2 field_name" so the jquery selector are always unique and it's good this way.
I have tried this with same key on each component in the two forms and it seems to be working.
Maybe we are not talking about the same thing ?
Comment #5
ashrafabedHere's a workaround for part of the issue:
This fix addresses the case where there are multiple webforms on one page, and only one of the webforms use conditionals.
Comment #6
densolis commentedAll,
I am helping tedbow with this module. I will be talking with him on Monday and bring this to his attention. One of us will update this status next week.
Dennis
Comment #7
simone960 commentedI encountered the same problem in 7.x-1.0-beta1. Any patch for this?