We need the ability to have multiple fields on our webform support the add more button. The attached patch updates the webform_add more module to treat add more fieldsets in different container fieldsets as different fields.

So all you need to do to have multiple fields as add more fields is to group each field in a fieldset.

For example:

  • Fieldset: Deliveries
    • fieldset: Delivery 1 (add more fieldset)
    • fieldset: Delivery 2 (add more fieldset)
    • fieldset: Delivery 3 (add more fieldset)
    • fieldset: Delivery 4 (add more fieldset)
  • Fieldset: Expenses
    • fieldset: Expense 1 (add more fieldset)
    • fieldset: Expense 2 (add more fieldset)
    • fieldset: Expense 3 (add more fieldset)
    • fieldset: Expense 4 (add more fieldset)

NOTE: This patch also requires the patch in #1497236: Support nested fieldsets Comment 2 to work.

Comments

shawn_smiley’s picture

Status: Active » Needs review
StatusFileSize
new3.16 KB

Here is the patch.

cmspagnola’s picture

Shawn,

This patch almost perfectly fixes an issue I was having in trying to have a form with two separate add more fieldsets. The issue I'm still having, though, is that deleting fields doesn't work as it should. I tried applying many of the patches on this forum to fix this issue (along with the ones that offer a remove button for removing previously added fields), but I'm unable to apply both your patch and those patches successfully given that they edit much of the same areas and my js and php skills are limited.

Is there any way you could include the patche found here: Remove Option or something similar?

If not, no worries, but I figured it wouldn't hurt to ask.

Thanks for your time,
Corinne

chertzog’s picture

I found that there was a problem selecting the parent fieldsets with multiple sets of "add more" fieldsets.

In Drupal.settings.webform_addmore.collections

        var parent_fieldset = $('#' + fieldset).parent('fieldset');

needs to be replaced with:

        var parent_fieldset = $('#' + fieldset).parents('fieldset');

As for the remove option. I am working on it.

chertzog’s picture

StatusFileSize
new8.88 KB

Here is a patch that is applied against the current 7.x dev branch. Other than the core declaration, i dont think there is anything that is 7.x specific, so it may not apply cleanly to the 6.x version, but it could be applied manually without to much effort.

It includes most of the other patches that have been submitted for this module to get it working in a somewhat suitable manner.

It includes the ability to have nested fieldsets, multiple fieldsets per page, and adds a remove option.

cmspagnola’s picture

This worked fantastically. Thank you very much for what you created. The only issue that seems to exist is when the row weights are changed for an item. An error occurrs and the item is no longer selected as an add more fieldset. This issue is by no means a major one, and is one I can deal with if you don't have time to fix it/don't feel the urge, but I wanted you to know it existed.

Thank you again for all your help.

czigor’s picture

Version: 6.x-1.x-dev » 7.x-1.01
Status: Needs review » Reviewed & tested by the community

#4 works on 7, thanks a lot!

DrupalDan’s picture

StatusFileSize
new257.6 KB

I got an error when applying the patch. Hope the screenshot makes it easy to identify the cause of it. Thanks

richsky’s picture

Remove option does'nt unset the fields vars in the fieldset....

castawaybcn’s picture

patch in #4 applied to 7.01 as czigor suggested does not seem to work in my case on a clean d7 installation.
I am getting this errors while viewing the webform page:

Notice: Undefined index: addlabel in webform_addmore_form_alter() (line 121 of /var/www/mysite/sites/all/modules/webform_addmore/webform_addmore.module).
Notice: Undefined index: dellabel in webform_addmore_form_alter() (line 122 of /var/www/mysite/sites/all/modules/webform_addmore/webform_addmore.module).

And no add more button shows up.

czigor’s picture

You need to set the addmore and delete button label at the webform addmore config page to make the notices go away.

castawaybcn’s picture

thanks for getting back with this czigor, perhaps I am doing something wrong here, but after going to WebForm advanced settings and setting the values for "add more button text" & "delete button text" I get this error:

    Notice: Undefined index: addlabel in webform_addmore_form_webform_configure_form_alter() (line 66 of /var/www/aadipa/sites/all/modules/webform_addmore/webform_addmore.module).
    Notice: Undefined index: dellabel in webform_addmore_form_webform_configure_form_alter() (line 71 of /var/www/aadipa/sites/all/modules/webform_addmore/webform_addmore.module).

The error message dissapears on refresh though.

However, when I visit my webform (two fieldsets with the add more option enabled, contained in another fieldset) the behaviour is a bit odd, here's what happens:

  1. I see the first fieldset with an add more button under it.
  2. The second fieldset does not show up.
  3. When I click on "add another" the second fieldset shows up.
  4. The "remove" fieldset option shows up, clicking on it makes the second fieldset dissappear.
  5. No "add another" button for the first fieldset.
CSoft’s picture

Here is a patch that is applied against the current 7.x dev branch

Thanks! But it is necessary also that during removal of fieldset its fields were cleared.

For example:

shownFieldsets.filter(':last').hide();

=>

shownFieldsets.filter(':last').hide().find(':input').val('');

jonfrancisskydiver’s picture

In the conditional right below
var collections = Drupal.settings.webform_addmore.collections;

I was getting an error saying that collections was undefined. It appears that Drupal.settings.webform_addmore only contains an array object of fieldsets. So my quick fix was:

if (typeof collections == 'undefined' || collections.length == 0) 
  collections = Array();
  collections.push('');
}  

This seemed to work well. What I changed was adding the test to see if collections was undefined. If it was, then I set collections to an empty array which allowed the push method to exist.

I did add a few other patches manually, perhaps one of them was messing the javascript up. I hope this helps someone.

Jonathan

michaellander’s picture

StatusFileSize
new1.41 KB

Attached is a patch that fixes the save issue when rearranging fields. It will probably fix node clone issues as well.

The patch should be applied after the patch in comment #4:
#1696868-4: Support having multiple add more fields on a form

I wrote it pretty quickly, so please test it before putting it on a production site, but it's pretty straight forward so I don't expect any issues.

chertzog’s picture

Status: Reviewed & tested by the community » Fixed

I finally got some time to update this module. Most of the outstanding issues have been addressed.

http://drupalcode.org/project/webform_addmore.git/commit/64920f2

michaellander’s picture

Thanks chertzog! Would you consider checking out the patch I posted above? It should fix the issue with the addmore setting becoming unchecked if you rearrange the fields and possibly the node clone issue as well.

chertzog’s picture

I believe i included your patch in the update. I had included most of the patches that were needed to get this module working in any sort of fashion.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added note about dependency on another patch.