I have created a webform like this:

Contact Fieldset
- text fields
- Add More not checked

Page Break

Booking Fieldset
- fields
- Add More checked

Booking Fieldset
- fields
- Add More checked

I get a one Booking fieldset on the second page, but the Add More button text is "Add More,Add More". If I change the form settings the new text is duplicate, eg "Add Booking,Add Booking". If I remove the page break, it's fine.

Comments

matt b’s picture

When pagebreaks are on the form, and you page forward to the page with the fieldsets on it, the webform_addmore_form_alter function (and therefore drupal_add_js) runs twice - I'm not sure why - page forward again and then page back webform_addmore_form_alter only runs once.

The drupal_add_js function is additive.

Calling drupal_add_js to set the javascript variable for the label text twice turns the javascript label variable from a string to an array. When this is displayed on the button, the array is rendered twice, causing button label text duplication.

I've fixed this in the javascript file by changing this line:
fieldsetRepeater($('.webform-client-form'), '.webform-addmore', Drupal.settings.webform_addmore.label, 1);
to

    if (Drupal.settings.webform_addmore.label.constructor==Array) 
      fieldsetRepeater($('.webform-client-form'), '.webform-addmore', Drupal.settings.webform_addmore.label[0], 1);
    else
      fieldsetRepeater($('.webform-client-form'), '.webform-addmore', Drupal.settings.webform_addmore.label, 1);
bellesmanieres’s picture

Issue summary: View changes
Status: Active » Closed (outdated)