data['infomaterial']) == 0 ) { return;}$files_array = array ( 1 => JPATH_SITE.'/download/a.pdf', 2 => JPATH_SITE.'/download/b.pdf', 3 => JPATH_SITE.'/download/c.pdf',);$attach_files = array();foreach ( $files_array as $k => $v ) { if ( in_array($k, $form->data['infomaterial']) ) { $attach_files[] = $v; }}$form->data['file_array'] = $attach_files;?>And I assure I entered {file_array} in the attachments field in your email [GH] 'action'.Please help."> Problem with multiple attachments depending on checkbox - Forums

Forums

Problem with multiple attachments depending on checkbox

merzmedia 01 Jun, 2013
Hi Greyhead😉

EDIT:

I developed a custom action myself that also shows the filenames in the email text-content.

Thanks anyway.

Original post:

Hi Greyhead😉

I spent hours and hours with the following problem:

I the current Version of CF, your "custom Email [GH]"
and your snippet I found here: http://www.chronoengine.com/faqs/view/2 ... email.html

Problem:
When I add {file_array} in the attachments field, nothing is sent.
But when debugging the 'file_array' looks perfect, but no attachment is sent.
When entering the server path and filenames manually, everything is sent properly.

The custom code (mode: controller) I use:
<?php
if ( !isset($form->data['infomaterial']) || count($form->data['infomaterial']) == 0 ) {
  return;
}
$files_array = array (
  1 => JPATH_SITE.'/download/a.pdf',
  2 => JPATH_SITE.'/download/b.pdf',
  3 => JPATH_SITE.'/download/c.pdf',
);
$attach_files = array();
foreach ( $files_array as $k => $v ) {
  if ( in_array($k, $form->data['infomaterial']) ) {
    $attach_files[] = $v;
  }
}
$form->data['file_array'] = $attach_files;
?>

And I assure I entered {file_array} in the attachments field in your email [GH] 'action'.

Please help.
Max_admin 06 Jun, 2013
Hi,

I'm not sure how the "Email - GH" action works, but for the default one, if you inject your fields info into the $form->files array then add the fields names into the "Attachments fields names" box in the "Email" action then they should be attached.

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
merzmedia 07 Jun, 2013
See EDIT in first post.

Thanks

( now I think I deserve a beer myself😉 )
GreyHead 07 Jun, 2013
Hi merzmedia,

As far as I know from my tests and from other users the code in the FAQ that you copied works OK. Is it possible that in your tests the data returned from the checkbox group was no longer an array?

Bob
merzmedia 16 Jun, 2013

Hi merzmedia,

As far as I know from my tests and from other users the code in the FAQ that you copied works OK. Is it possible that in your tests the data returned from the checkbox group was no longer an array?

Bob



maybe - should I exclude the fieldname from CF "Handle Arrays"?

Or maybe I have something wrong in the order of the actions:

1. generate files array
2. handle arrays
3. Email [GH]

Anything else I have to activate?
This topic is locked and no more replies can be posted.