Good morning. How are you?
I would like to add the following functionality to a form:
1) checkboxes
2) each checkbox has associated an image or a pdf file
3) on submit the files associated with the checked checkboxes are sent as attachments to an email.
4) ideally I would like the sending to be done after payment (through paypal) is received.
Please can you point me to where I should look?
Related to this but a separate point: what would be the best approach to displaying an image (possible saved in a table) based on a value in a dropdown?
Many thanks
Kind regards
Amelia
I would like to add the following functionality to a form:
1) checkboxes
2) each checkbox has associated an image or a pdf file
3) on submit the files associated with the checked checkboxes are sent as attachments to an email.
4) ideally I would like the sending to be done after payment (through paypal) is received.
Please can you point me to where I should look?
Related to this but a separate point: what would be the best approach to displaying an image (possible saved in a table) based on a value in a dropdown?
Many thanks
Kind regards
Amelia
Hi Amelia,
1. Add a Checkbox Group element to your form
2. Use a Custom Code action to set the names + paths of the associated images depending on the CheckBox settings. Add the values to the $form->files array - please see this FAQ
3. If you assign the files to a sub-array of $form->files e.g.g $form->files['user_files'] you should be able to add this to the Attachments box in the Email action.
4. Get the above working first. Then set up a form using the PayPal method you need - it will have to use IPN to give you confirmation of payment. You can then re-create the Custom Code and Email action in the PayPal Listener action to send the email once payment is confirmed.
Bob
1. Add a Checkbox Group element to your form
2. Use a Custom Code action to set the names + paths of the associated images depending on the CheckBox settings. Add the values to the $form->files array - please see this FAQ
3. If you assign the files to a sub-array of $form->files e.g.g $form->files['user_files'] you should be able to add this to the Attachments box in the Email action.
4. Get the above working first. Then set up a form using the PayPal method you need - it will have to use IPN to give you confirmation of payment. You can then re-create the Custom Code and Email action in the PayPal Listener action to send the email once payment is confirmed.
Bob
Hello Bob
Thank you for answering. It is a bit confusing for me.
In step 2 would the code:
<?php
$form->files["field_name"]["path"] = "ABSOLUTE SERVER PATH TO FILE HERE";
?>
set the settings for only one file under the name "field_name". Since I want to set up several attachments I would have to use different names like "file_name1", "file_name2" etc instead of "field_name" is this right?
Now in step 3 are you saying that I simply write $form->files in the Attachments box and all the files set up in step 2 would be taken from this array and emailed?
Thank you
Amelia
Thank you for answering. It is a bit confusing for me.
In step 2 would the code:
<?php
$form->files["field_name"]["path"] = "ABSOLUTE SERVER PATH TO FILE HERE";
?>
set the settings for only one file under the name "field_name". Since I want to set up several attachments I would have to use different names like "file_name1", "file_name2" etc instead of "field_name" is this right?
Now in step 3 are you saying that I simply write $form->files in the Attachments box and all the files set up in step 2 would be taken from this array and emailed?
Thank you
Amelia
Hello Bob
I got 1 and 2 working well.
On 3. I can only get it to send the attachments if I specify each of these by the name of the field I set when I added them to the array $form->files.
Is this the best that can be done?
Thank you
Amelia
I got 1 and 2 working well.
On 3. I can only get it to send the attachments if I specify each of these by the name of the field I set when I added them to the array $form->files.
Is this the best that can be done?
Thank you
Amelia
Hi Amelia,
I got this to work on a test form
Bob
I got this to work on a test form
<?php
$files = array(
'file_name_a.png',
'file_name_b.png'
);
$path = JPATH_SITE.'/components/com_chronoforms5/uploads/folder_name/';
foreach ( $files as $k => $f ) {
$form->files['files_to_send'][$k]['path'] = $path.$f;
}
?>Then add files_to_send in the Email action Attachments box. Your folder path will be different too, and the first part of the code here should be replaced with the code to pick files from the checkboxes.
Bob
This topic is locked and no more replies can be posted.
