1

I haven't been able to find a single example of how to create a webform with a managed_file type.

The webform initially had the type 'file', but needs to be changed to accept multiple attachments. When the type is changed to 'managed_file', the field for uploading attachments does not render.

Here is my code snippet for the attachment field:

7 => array(
    'name' => t('Attachment'),
    'form_key' => 'attachment',
    'type' => 'managed_file',
    'upload_location' => NULL,
    'pid' => 1,
    'weight' => 6,
    'value' => '',
    'required' => '0',
    'extra' => array(
      'directory' => 'story',
      'title_display' => 'before',
      'private' => 0,
      'wrapper_classes' => '',
      'css_classes' => '',
      'filtering' => array(
        'size' => '2 MB',
        'types' => array(
          'gif',
          'jpg',
          'jpeg',
          'png',
          'txt',
          'rtf',
          'html',
          'pdf',
          'doc',
          'docx',
          'ppt',
          'pptx',
          'xls',
          'xlsx',
          'zip',
        ),
        'addextensions' => '',
      ),
      'rename' => '',
      'scheme' => 'public',
      'progress_indicator' => 'throbber',
      'description' => '',
      'attributes' => array(),
      'analysis' => FALSE,
    ),
  ),
);

Thanks much!

0

Making a couple of leaps here:

  1. I couldn't find a D8 release for Webform so assuming D7
  2. I'm assuming by managed_file (which is a FAPI element type) you mean a field API file field, as you mentioned making it accept multiple files (which the managed_file element doesn't have any support for).

So with those in mind...

Webform implements its own set of components, of which file is one type; it doesn't use the field API, so unfortunately you can't attach field API fields of any type to it.

The out-of-the-box file component doesn't support multiple uploads, but there's a contributed module, Webform Multiple File, which does:

Module Webform Multiple File provides new Webform component for multiple file uploading. The module based on principles of file field widget and has similar design.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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