1

I managed to add fields to submit attachments in a webform. Now all I need is to restyle them to only allow one upload per charge plus a 'add more button'. I need to restyle the 1 into 2.

How can this easily achieved?

enter image description here

2 Answers 2

1

Have you checked this Webform Add module ?

Webform Add More enables selected fieldsets to be initially hidden and progressively shown with an Add more button, mimicking CCK multiple fields.

3
  • I was not able to find that checkbox to activate the module. This would be what I am looking for. Dec 14, 2012 at 13:12
  • Also is working inside fieldsets which is not possible in my situation Dec 14, 2012 at 13:36
  • 1
    I have hundreds of forms and I need a programmatic way to do this. Jan 21, 2013 at 10:16
0

I found a solution which relies on javascript, here below is the skeleton:

    $("#edit-submitted-file-ajax-wrapper").after('<a id="addmore" href=#>[+] Add more</a>');
          //this vars are available inside bind function due to js scope
          var c = 1;//counter
          var wrapper_to_clone;
          $('#addmore').bind('click', function(e) {
            //clone filed and change attributes
            wrapper_to_clone = $("#edit-submitted-file-ajax-wrapper");
            field_to_clone = $("#edit-submitted-file-ajax-wrapper input");
            wrapper_to_clone.clone().attr('id', 'edit-submitted-file' + c + '-ajax-wrapper').insertAfter(wrapper_to_clone);
            //here you need to rename the attributes of children
            ...    
            ++c;

            if (c == 5) {
              return false;
            }
     });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.