Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
ref #623692: Multiple File Upload - send as attachment
For the moment there's no way to send the attachment by email, since the code used to attach the file assumes a a $fid as parameter, which we don't have (we have an serialized array)
if ($email['attachments']) {
webform_component_include('file');
foreach ($node->webform['components'] as $component) {
if (webform_component_feature($component['type'], 'attachment') && !empty($submission->data[$component['cid']]['value'][0])) {
$file = webform_get_file($submission->data[$component['cid']]['value'][0]); // <== Doesn't work
if ($file) {
$attachments[] = $file;
}
}
}
}
<
I'll try to fix it
Comments
Comment #1
quicksketchThis looks pretty good, but if we're going to be adding a hook (or Webform's version of a hook), we should make the file component implement it too instead of special-casing the built-in component. Then it makes for an example that other modules could reference. Unless we have other purposes, calling the hook "attachments" might be a suitable name (so file.inc would have _webform_attachments_file()). We also need documentation of the new hook in webform_hooks.php.
Comment #2
Jelle_STwo patches attached, one for 6.x and one for 7.x
Comment #3
Jelle_SForgot to edit a part of the comments in webform_hooks.php after copy-pasting them
Comment #4
Jelle_SFixed some minor mistakes in the documentation
Comment #5
quicksketchLooks pretty good buy you're missing the implementation of the new hook in components/file.inc.
Comment #6
Jelle_Shere it is... It just reuses the existing function webform_get_file :-)
Comment #7
Jelle_SComment #8
quicksketchThanks Jelle_S, you're quite right. I finally got a chance to review this patch in earnest today and it works great. Committed to both 3.x branches. Extra props for the D6 backport.