First of all, thank you so much for this module. It's a big help.

Maybe I'm an idiot but I can't seem to get it to work. I have two textfields in a fieldset and I've activated the "add more" checkbox.

When I go to view the form I don't see the button to add more... Am I missing something?

Comments

john.money’s picture

Assigned: Unassigned » john.money
Status: Active » Postponed (maintainer needs more info)

Need some more information here:

  • Have you edited two or more fieldset components and checked the Add more fieldset checkbox?
  • Are the proper fieldsets being hidden? If so, then the JS is working but there is likely some issue with the button itself.
  • If the fieldsets are not being hidden, is the JS even being included? (check your HTML and look for /sites/all/modules/webform_addmore/js/webform_addmore.js in the document head, as well as "webform_addmore": { "fieldsets": [ ... in the jQuery.extend(Drupal.settings).
  • What browser are you using?
dgautsch’s picture

Hi John, thanks for your help. here's my setup:

I'm using firefox and chrome on the latest release of drupal and I've confirmed the JS is in the header fields.

I didn't notice this before (error reporting was turned off) but I'm also getting the following error

Notice: Undefined index: label in webform_addmore_form_alter() (line 93 of ~/sites/all/modules/webform_addmore/webform_addmore.module).

Below is my form outline
Details (Fieldset with add more option enabled)
---Text Field
---Text Field
Options (Fieldset with add more option enabled)
---option 1
---option 2
---option 3

I have a feeling I haven't laid the form out the correct way.

Posthume’s picture

Hi,

I'm also getting this error :

Notice: Undefined index: label in webform_addmore_form_webform_configure_form_alter()

lsolesen’s picture

I think an explanation why and how you need to edit two or more fieldsets.

Say I create a form, where I want Add more button to participant info.

Fieldset: Order information
- Order number
- E-mail

Fieldset: Participant info
- Name
- Date of birth
-- Enabled Add more...

So that is two fieldsets, but the button does still not appear. Should the participant info be duplicated, should it be inclosed in another fieldset? I tried most combinations?

sylv3st3r’s picture

Did some research,

So this kind of problem will appear if you have a 'space' on your form key name. Example, you named your fieldset "Participant Info" it will have "participant_info" key name, but Webform module/ Drupal will render the form key to "participant-info", notice it replace the underscore "_" with dash "-"

So try to change this:

$form_key[] = 'webform-component-' . $form['#node']->webform['components'][$cid]['form_key'];

into

$form_key[] = 'webform-component-' . str_ireplace('_','-',$form['#node']->webform['components'][$cid]['form_key']);

On webform_addmore.module line 85.

Also there's a lot of bug here actually, for instance, if you use webform module "clone" feature, it will not have "cid" on line 37 :
$settings[$component['cid']] = $component['display']['addmore'];

Hope that fix the button not appearing.

-r

john.money’s picture

Category: support » bug
Status: Postponed (maintainer needs more info) » Active

sylv3st3r is correct. The bug some are encountering related to rendering the fieldset name. I should be able to code around this, but in the interim, please test with single word fieldset keys (e.g. participant-info or participant1).

Putting the other issue with cloning fieldsets on bug to do list.

lsolesen’s picture

Actually I did it in Danish so there is no space in my form name (and hence not in the key name).

vmkazakoff’s picture

I have the same problem.

Try to use 1 word-long name for fieldset, but when I checking the "Add More fieldset" checkbox and save changes, it is not saved :(

If I open edit/components/.. page I dont have the checkbox checked

Where my mistake?

And one another time I ask about @two or more@ - what the structure is? Do thay need to be in one webform? I can put it together, or I need put one of it as child of enother? And why?

and one more: THANKS YOU for the grate module! It help me very much!!!

visualnotion’s picture

It isn't appearing for me, either, but I'm using Drupal 6. I've tried using one-word fieldset names, etc. It's still not working. Any ideas?

lsolesen’s picture

I flushed the cache a couple of times, and now the button appeared. From the description I misunderstood the concept, as it seems that you need to create two identical fieldsets if you want the addmore button. I the module can only hide the second fieldset and show it. It cannot add more fieldsets dynamically.

Anonymous’s picture

I made the changes proposed sylv3st3r in #5, but the button is still not visible.

It seems the reason is undefined variable "fieldsets" on line "var hiddenFieldsets = fieldsets.not(':visible');" in "webform_addmore.js" it will be defined later.

    function fieldsetRepeater(container, fieldsetSelecter, addBtnTxt, numberFirstShown) {
      var addBtn = $('<input type="button" class="add-more" />').val(addBtnTxt).click(function() {
        var hiddenFieldsets = fieldsets.not(':visible');

        hiddenFieldsets.filter(':first').fadeIn();
        if(hiddenFieldsets.size() < 2) {
          addBtn.hide();
        }
      });

      var fieldsets = container.find(fieldsetSelecter)
      .not(container.find(fieldsetSelecter + ' ' + fieldsetSelecter))
      .hide();

Fix:

    function fieldsetRepeater(container, fieldsetSelecter, addBtnTxt, numberFirstShown) {
      var fieldsets = container.find(fieldsetSelecter)
      .not(container.find(fieldsetSelecter + ' ' + fieldsetSelecter))
      .hide();

      var addBtn = $('<input type="button" class="add-more" />').val(addBtnTxt).click(function() {
        <strong>var hiddenFieldsets = fieldsets.not(':visible');</strong>

        hiddenFieldsets.filter(':first').fadeIn();
        if(hiddenFieldsets.size() < 2) {
          addBtn.hide();
        }
      });

p.s.
Sorry for bad English.

matthew.woodard’s picture

Any reason the webform_addmore.js wouldn't be showing up?

- I have the module enabled
- There are 2 fieldset (both with "Add More" option checked)

Ran Cron / Flushed Cash ... any ideas?

matt b’s picture

Version: 7.x-1.01 » 6.x-1.03

Using a single word fieldset key as per #6 worked around this for me, even with cloned fieldsets.

BMorse’s picture

I had it working by using the single word fieldset key but when I cloned one to add a 3rd fieldset it stopped working.

dubois’s picture

I received the error message in #2 when using single word fieldset field keys. However, these resolved with a cache-clear all.

cbrasfield’s picture

I was also getting the error Notice: Undefined index: label in webform_addmore_form_webform_configure_form_alter() on line 94.

I added an isset function to the ternary operation:
'label' => isset($settings['label']) ? t($settings['label']) : t('Add more'),

cbrasfield’s picture

I was also experiencing the Undefined index:cid error when attempting to clone items.

I noticed in Webform, the cid was unset in cloning but never actually reset. So I modifed webform.components.inc as:

// ~ Line 855 (webform 3.16)
 $original_cid = $component['cid'];
  //unset($component['cid']); 
  $component['cid'] = "";
  $new_cid = webform_component_insert($component);
  $component['cid'] = $new_cid;

And in the webform_component_insert function at line 735, I changed if (!isset($component['cid'])) { to if ($component['cid']=="") {

Now it works without the cid index error. HOWEVER, there's no delete function associated with this module, so if you remove a field, you get an notice saying there's an offset error. I added the webform delete hook below the presave function as follows


function webform_addmore_webform_component_delete($component) {
  if ($component['type'] != 'fieldset') {
    return;
  }
  $settings = variable_get('webform_addmore_' . $component['nid'], array());
  unset($settings[$component['cid']]);
  variable_set('webform_addmore_' . $component['nid'], $settings);
}

This has not undergone extensive testing, but it seems to be working for me....at the moment.

strager-1’s picture

Has this been fixed yet? I can't use this module until it is..... Spaces are mandatory for another module.....

otmoroz095’s picture

You're right!
I've changed my key "article_info" to "artinfo" and now i can see button! YYeaH! Thank you, (wo)man!

danny englander’s picture

I just ran into this issue as well / getting the same error message. I tested with a single word fieldset key but still no joy. (I also Made sure the Add More fieldset is checked, cleared cache and ran cron.)

I am also confused, the version number for this issue was changed midway from 7.x to 6.x in #13, was that intentional? I am using Drupal 7.14 so in that case should I file a separate issue?

fdefeyter@gmail.com’s picture

Hi there!

Thanks for developping this module. But I can't use it:

The JS is not loaded in the page. I added it from the html.php but it doesn't work. I will try via the .info file.

So of course, the button is not showing...

I really don't know how to resolve this...

I can see the usage statistics of this wonderfull module is falling to zero... Is that because of the version of the webform module compatibility?

Please help :-)

Thanks in advance...

fdefeyter@gmail.com’s picture

OK so finally I made it working. Sorry for my precedent post.

I first thought it was a loop: so that you could repeat the same fieldset as much as you wanted.

But it's not the case. You have to manually prepare all the fields you want.

So first, cerate a fieldset and select "addmore fieldset in the options".

Then add you fields like on a normal fieldset.

Create at least 2 like that.

Enjoy :-)

Thanks for coding to the author!

vinmassaro’s picture

We ran into this bug and came across this thread. Having to know to change the machine names of the fieldsets is non-obvious.

pivwani’s picture

I spent hours trying to figure this out. After a lot of trials I managed to get this working as intended. I wanted to give a basic step by step to help save you some time.

Enable Webform addmore in modules
create content and choose webform.
Fill in all the normal stuff that you require
you can then add your specific fields, you will see 'new component name" faded. Add anything you like with spaces if ness
you must select fieldset in the type column and click 'add'

you will then see the field key enter a name for eg 'part1'. Do not use spaces unless you have altered the code as described above, it isnt really neccessary to have more than one work in the key, no one will see it. Its a machine name.

In the display box, and this is vital to get the button to appear. Only have selected 'hide label' and 'add more fieldset'. This is crucial.

Click save component

You can then add any option you like for eg 'Part number' The type can be anything you like or require

You then need to move this item under the fieldset you made previously and drag to the right, like parent & child in taxonomy etc.

Once you have done this, repeat it all again, create another field set, and also add the same option like 'part number'.

Remember the field keys need to be unique.

Once you have sorted out all of your options and layed it out, go back to edit each field set nd click back on, add more fieldset, check them all, for some reason when moving and altering fields and adding more it uncheck the field.

You should end up with something like this www.enginepartsuk.net/order-enquiry

I changed the .js file to in the webform addform module folder so it used my classes to make the button the same as the rest. This is isnt neccessary, but I think it looks better.

Sorry if this is a little basic for some users, this is my first post on the drupal forum. I have taken so much from these forums nd want to give something back.

Fujiedo’s picture

Thanks a lot pivwani. This is it; no changing the code or .js. Works on Drupal 7 for me.

alok.tripathi’s picture

Thanks Pivwani. 'Add more' button is now working for me in drupal-6.

alok.tripathi’s picture

Issue summary: View changes

Spelling fixes.

houstonaplus’s picture

My issue is the javascript file is not showing up in the head section. The fieldset label is hidden and the "Add More" checkbox is active.

new123456789’s picture

So, I created two identical feildsets, the only difference is that the second set has a number 2 appended at the end of each field key (eg name2).

Hmmm. I seem to be unable to save the Add More fieldset option... Whenever I select the checkbox, select Save compontent... then go back in to check... the tick disapears????

Also, I keep getting this error every time, I try and close the form compontetns page:

To display this page, Firefox must send information that will repeat any action (such as a search of order confirmation) that was performed earlier.

I am running drupal 7 tho...

ssoulless’s picture

Issue summary: View changes

Any update in this? Im getting the same problems here

jorisx’s picture

Not Working at all with:
Drupal, 7.27
Webform, 7.x-3.20
Webform Add More, 7.x-1.2
...
All created fiedsets with 'add more' enabled' are just all shown, no buttons and nothing is hidden??!

ssoulless’s picture

this is broken for drupal 7.29 and webform 4.x too

pivwani’s picture

SSouless

Please follow my instructions above. If not tell me what's happening.

Thanks

Works on all D7 inc 7.31

Pascal.s’s picture

Ad the same problem!
#22 works for me. Maybe add more step in the README file would help a lot of people.
THANKS!

bellesmanieres’s picture

Status: Active » Closed (outdated)