Hai,
Now i dont want people to give me an attachment, but i want to give it to them.
I made a form, where people can pick a document (with a checkbox or radiobutton)
When people push SEND they receive the document they picked.
Is that even possible, when it is pleease help me! because i want to know!🤔 🤔 🤔
Greettzz
Annelies
Now i dont want people to give me an attachment, but i want to give it to them.
I made a form, where people can pick a document (with a checkbox or radiobutton)
When people push SEND they receive the document they picked.
Is that even possible, when it is pleease help me! because i want to know!🤔 🤔 🤔
Greettzz
Annelies
Hi Annalies,
Have you solved this? It is possible, you need to add the correct form path to the Email $attachments array.
Bob
Have you solved this? It is possible, you need to add the correct form path to the Email $attachments array.
Bob
Hi Annalies,
Have you solved this? It is possible, you need to add the correct form path to the Email $attachments array.
Bob
I'm assuming you mean in the php code itself. I'm not a coder by any stretch, so can you elaborate? Maybe a coding example of what Annalies was suggesting would work?
Hello, I want to do the same with the form like Annelies but can't find the answer how to do this. my form sends one or two attachments without a problem. but i don't know how to realize that the user can select a document by picking a checkbox.
Hi misfit,
You can do this in the OnSubmitBefore box. Here's some outline code:
Bob
You can do this in the OnSubmitBefore box. Here's some outline code:
<?php
$check_0 =& JRequest::getString('check_0', '', 'post');
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
switch ( $check_0 ) {
default:
$MyUploads->attachments[] = 'some_path'.DS.'file_0';
break;
case 1:
$MyUploads->attachments[] = 'some_path'.DS.'file_1';
break;
case 2:
$MyUploads->attachments[] = 'some_path'.DS.'file_2';
break;
}
?>
Bob
hey, first sorry for my bad english:) and my stupid questions.
i have same problem like misfit and tryed the code from greyHead.
The result was: Mails arrived but without Attchment - and this was showen on frontpage:/components/com_chronocontact/libraries/customcode.php(64) : eval()'d code on line 2
can anybody help me out here?
Thanx
P.
i have same problem like misfit and tryed the code from greyHead.
The result was: Mails arrived but without Attchment - and this was showen on frontpage:/components/com_chronocontact/libraries/customcode.php(64) : eval()'d code on line 2
can anybody help me out here?
Thanx
P.
Hi ssbFirefly,
The code posted by Bob can't be used without few changes based on your form fields names and your server path and your files names.
Please show us the full error you get on your web page ? or a screenshot ?
Regards,
Max
The code posted by Bob can't be used without few changes based on your form fields names and your server path and your files names.
Please show us the full error you get on your web page ? or a screenshot ?
Regards,
Max
Hi ssbFireFly,
Just noticed a typo in Line 2 of my code
I'll fix the earlier post.
Bob
Just noticed a typo in Line 2 of my code
$check_0 =& JRequest:getString('check_0', '', 'post');
should be $check_0 =& JRequest::getString('check_0', '', 'post');
with ::I'll fix the earlier post.
Bob
Hey Max & GreayHead, thanx for your help!
Now the error is gone::) But now my problem is, if i check the checkbox 1 or 2 or both it is always the same attachment in the mail?
can you maybee check if i do something wrong with the path or file?
If i understand right, the "default" in line 6 means, if nothing is checkt it will send 1st attachment?
Hmmm? My idea is:
a minimum of 1 checkbox is required of 3, 1st checkbox 1st attachment, 2nd checkbox 2nd attachment,
3rd checkbox both attachments.
and on a second checkbox arria to chose if you want to recive the Docs per Mail or Postway.
hope you can help me out here.
best regards
p.
Now the error is gone::) But now my problem is, if i check the checkbox 1 or 2 or both it is always the same attachment in the mail?
can you maybee check if i do something wrong with the path or file?
<?php
$check_0 =& JRequest::getString('check_0', '', 'post');
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
switch ( $check_0 ) {
default:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'ssb_waiver.pdf';
break;
case 1:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'aff_anmeldung.pdf';
break;
case 2:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'ausschreibung_6er.pdf';
break;
}
?>
If i understand right, the "default" in line 6 means, if nothing is checkt it will send 1st attachment?
Hmmm? My idea is:
a minimum of 1 checkbox is required of 3, 1st checkbox 1st attachment, 2nd checkbox 2nd attachment,
3rd checkbox both attachments.
and on a second checkbox arria to chose if you want to recive the Docs per Mail or Postway.
hope you can help me out here.
best regards
p.
Hi ssbFirefly,
You'll need to change the logic to get the result you want, and to add validate-one-required to the check-box group to make sure that at aleast one box is checked.
The 'default' means that that file will be attached if check_0 doesn't return 1 or 2.
What are the values set for check_0 in your form?
Bob
You'll need to change the logic to get the result you want, and to add validate-one-required to the check-box group to make sure that at aleast one box is checked.
The 'default' means that that file will be attached if check_0 doesn't return 1 or 2.
What are the values set for check_0 in your form?
Bob
Hey GreyHead,
The validate-one-required works fine.
What do you mean with "change the Logig"?
I tryed this:
but it returns only "0" (aff_amledung.pdf) on every checkbox.
do you have an idea?
cy
P.
The validate-one-required works fine.
What do you mean with "change the Logig"?
I tryed this:
<?php
$check_0 =& JRequest::getString('check_0', '', 'post');
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
switch ( $check_0 ) {
default:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'bw2er_ausschreibung.pdf';
break;
case 0:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'aff_anmeldung.pdf';
break;
case 1:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'ausschreibung_6er.pdf';
break;
case 2:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'ssb_waiver.pdf';
break;
}
?>
but it returns only "0" (aff_amledung.pdf) on every checkbox.
do you have an idea?
cy
P.
Hi ssbFirefly,
"Change the logic" : at present the code logic is to send only one attachment; you need to alter the code if you want it to send two or three.
Bob
"Change the logic" : at present the code logic is to send only one attachment; you need to alter the code if you want it to send two or three.
Bob
Ok understand. Do you can dive me an example in a code how i can do this?
cy
P.
cy
P.
Hi ssbFirefly,
If you remove the 'break;' lines it should do what you want I think:
Bob
If you remove the 'break;' lines it should do what you want I think:
switch ( $check_0 ) {
default:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'bw2er_ausschreibung.pdf';
break;
case 0:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'aff_anmeldung.pdf';
case 1:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'ausschreibung_6er.pdf';
case 2:
$MyUploads->attachments[] = 'images/stories/dokumente/'.DS.'ssb_waiver.pdf';
}
Break ends the switch and no more cases are tested; without the break the following cases are tested as well.Bob
I have a client (purchased 3 domain license) that wants an email sent w/ the associated attached files they select in the form. Using your code minus the 'break;' all files are being sent no matter what is selected. If I insert the 'break;' then only the 'default:' file is sent no matter which one is selected.
On Submit code - before sending email:
I'm a novice at php coding but, have done as much due diligence as possible to find out why it's not just sending what has been 'checked'. The only thing I can think of is that I'm missing something to associate the above code w/ the associated form html code.
Any assistance would be greatly appreciated. Thanks!
On Submit code - before sending email:
<?php
$check_0 =& JRequest::getString('check_0', '', 'post');
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
switch ( $check_0 ) {
default:
$MyUploads->attachments[] = 'dmdocuments/'.DS.'Intelligent ATTENDANCE.pdf';
case 1:
$MyUploads->attachments[] = 'dmdocuments/'.DS.'Intelligent EXHIBITOR.pdf';
case 2:
$MyUploads->attachments[] = 'dmdocuments/'.DS.'intelligent_leads_product_brochure.pdf';
case 3:
$MyUploads->attachments[] = 'dmdocuments/'.DS.'intelligent_connect_product_brochure.pdf';
}
?>
I'm a novice at php coding but, have done as much due diligence as possible to find out why it's not just sending what has been 'checked'. The only thing I can think of is that I'm missing something to associate the above code w/ the associated form html code.
<div class="form_item">
<div class="form_element cf_checkbox">
<label class="cf_label" style="width: 150px;">Products</label>
<div class="float_left">
<input value="check 1" title="" class="radio validate-one-required" id="check00" name="check0[]" type="checkbox" />
<label for="check00" class="check_label">check 1</label>
<br />
<input value="check 2" title="" class="radio validate-one-required" id="check01" name="check0[]" type="checkbox" />
<label for="check01" class="check_label">check 2</label>
<br />
<input value="check 3" title="" class="radio validate-one-required" id="check02" name="check0[]" type="checkbox" />
<label for="check02" class="check_label">check 3</label>
<br />
Any assistance would be greatly appreciated. Thanks!
Hi gwells,
Your switch case statements are checking for 1, 2 or 3 but the values of the checkboxes in the HTML are 'check 1', 'check 2' and 'check 3'. The result will be that only the 'default' case is ever matched - because it is used when no other match is found.
Please try case 'check 1': etc.
Bob
Your switch case statements are checking for 1, 2 or 3 but the values of the checkboxes in the HTML are 'check 1', 'check 2' and 'check 3'. The result will be that only the 'default' case is ever matched - because it is used when no other match is found.
Please try case 'check 1': etc.
Bob
Thanks for the timely reply. I changed the following code but, unfortunately it still sends all of them.
Btw - debug shows:
Which products would you like more information on?
Products
check 3
Files: dmdocuments//Intelligent ATTENDANCE.pdf, dmdocuments//Intelligent EXHIBITOR.pdf, dmdocuments//intelligent_leads_product_brochure.pdf, dmdocuments//intelligent_connect_product_brochure.pdf
<?php
$check_0 =& JRequest::getString('check_0', '', 'post');
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
switch ( $check_0 ) {
default:
$MyUploads->attachments[] = 'dmdocuments/'.DS.'Intelligent ATTENDANCE.pdf';
case 'check 1':
$MyUploads->attachments[] = 'dmdocuments/'.DS.'Intelligent EXHIBITOR.pdf';
case 'check 2':
$MyUploads->attachments[] = 'dmdocuments/'.DS.'intelligent_leads_product_brochure.pdf';
case 'check 3':
$MyUploads->attachments[] = 'dmdocuments/'.DS.'intelligent_connect_product_brochure.pdf';
}
?>
Btw - debug shows:
Which products would you like more information on?
Products
check 3
Files: dmdocuments//Intelligent ATTENDANCE.pdf, dmdocuments//Intelligent EXHIBITOR.pdf, dmdocuments//intelligent_leads_product_brochure.pdf, dmdocuments//intelligent_connect_product_brochure.pdf
Hi gwells,
You need the breaks back in - otherwise all the cases after the one that is matched will be executed.
Bob
You need the breaks back in - otherwise all the cases after the one that is matched will be executed.
Bob
You are right about the breaks but, now it will only send the default file. My best guess is that it's still not associating with the html code for the check boxes.
p.s. Nothing above the switch code has changed from previous post.
switch ( $check_0 ) {
default:
$MyUploads->attachments[] = 'dmdocuments/'.DS.'Intelligent ATTENDANCE.pdf';
break;
case 'check 1':
$MyUploads->attachments[] = 'dmdocuments/'.DS.'Intelligent EXHIBITOR.pdf';
break;
case 'check 2':
$MyUploads->attachments[] = 'dmdocuments/'.DS.'intelligent_leads_product_brochure.pdf';
break;
case 'check 3':
$MyUploads->attachments[] = 'dmdocuments/'.DS.'intelligent_connect_product_brochure.pdf';
break;
}
?>
p.s. Nothing above the switch code has changed from previous post.
Hi gwells,
You're most likely right. As they are checkboxes, not radio buttons, the result will be an array. What do you want to have happen if more than one box is checked? Should all of the corresponding files be attached? If so the code needs to be a bit different.
Bob
PS You can output the value of $check_0 to see what it is.
You're most likely right. As they are checkboxes, not radio buttons, the result will be an array. What do you want to have happen if more than one box is checked? Should all of the corresponding files be attached? If so the code needs to be a bit different.
Bob
PS You can output the value of $check_0 to see what it is.
global $mainframe;
$mainframe->enqueuemessage('$check_0: '.print_r($check_0, true).'<hr />');
What do you want to have happen if more than one box is checked? Should all of the corresponding files be attached?
Yes, only the files associated with the checkboxes they checked off. What I have been doing is selecting the last check box 'check 3' to see if it will just send that one. There will be a total of five. More than likely the person filling out the form will only select 2 or 3 them.
My client is holding a conference and at the end of the conference they would like to know which products the potential client (basically a survey form) is interested in and immediately send them (via email attachment) that product brochure(s) when the form has been 'Submitted'.
p.s. Where can I insert the code?
global $mainframe;...
Hi gwells,
Please try this
Bob
Please try this
<?php
// Use this line if you have "Let ChronoForms handle arrays" set to 'NO'
$check0 = JRequest::getVar('check0', array(), 'post', 'array');
// Use these two lines if you have "Let ChronoForms handle arrays" set to 'NO'
//$check0 = JRequest::getString('check0', '', 'post');
//$check0 = implode(',', $check0);
if ( !count($check0) ) {
return;
}
$attachments = array(
'check 1' => 'Intelligent ATTENDANCE.pdf',
'check 2' => 'Intelligent EXHIBITOR.pdf',
'check 3' => 'intelligent_leads_product_brochure.pdf',
'check 4' => 'intelligent_connect_product_brochure.pdf',
'check 5' => '?????.pdf'
);
$attach = array();
foreach ( $check0 as $v ) {
$attach[] = JPATH_SITE.DS.'dmdocuments'.DS.$attachments[$v];
}
if ( !count($attach) ) {
return;
}
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
$MyUploads->attachments = array_merge($MyUploads->attachments, $attach);
?>
Bob
Success!
The second line of code you provided I commented out because I had "Let ChronoForms handle arrays" set to 'YES'
but, that didn't work so I uncommented it and set "Let ChronoForms handle arrays" set to 'NO' and it's working!!
I have two more questions.
Question 1: These files average about 2 megs each (marketing material :wink: ). If I select two or more and click 'Submit' it's taking some time to redirect because (I'm assuming) it's processing the email plus attachments. My question is can I have it redirect after hitting 'Submit' so that the processing occurs in the background (at least to the end user) and avoid them thinking that it's not working and continuing to click 'Submit' or think it's broken? If yes, how would I do that?
Question 2: I'm able to change the labels on the form from 'check 1' to the 'product title' but, when I get the email (w/ the attachments I selected!) it's showing me 'check 1', 'check 2' e.g. and of course I would like the end user to see the product title instead of. I see that in the 'Email Templates' {check0}. I can probably figure this one out but, thought I would ask if it's a quick answer.
Again, thank you for your assistance!
The second line of code you provided I commented out because I had "Let ChronoForms handle arrays" set to 'YES'
$check0 = JRequest::getVar('check0', array(), 'post', 'array');
but, that didn't work so I uncommented it and set "Let ChronoForms handle arrays" set to 'NO' and it's working!!
I have two more questions.
Question 1: These files average about 2 megs each (marketing material :wink: ). If I select two or more and click 'Submit' it's taking some time to redirect because (I'm assuming) it's processing the email plus attachments. My question is can I have it redirect after hitting 'Submit' so that the processing occurs in the background (at least to the end user) and avoid them thinking that it's not working and continuing to click 'Submit' or think it's broken? If yes, how would I do that?
Question 2: I'm able to change the labels on the form from 'check 1' to the 'product title' but, when I get the email (w/ the attachments I selected!) it's showing me 'check 1', 'check 2' e.g. and of course I would like the end user to see the product title instead of. I see that in the 'Email Templates' {check0}. I can probably figure this one out but, thought I would ask if it's a quick answer.
Again, thank you for your assistance!
Hi gwells,
I've lost track of the threads here :-(
I don't have a good answer to Q1; it might be possible to do something with a Flash uploaded to show a progress spinner (Fredrik [nml375] had a thread on this a while back), but ChronoForms can't process the files until they are uploaded so there's no easy answer to that.
You can set the option values to something more meaningful - if so then you need to track that through and make corresponding changes in the attachment code.
Personally I tend to make the code a little more complex and to look up values after the form is submitted. So, for example I'd keep check_0, check_1 as the values in the Form HTML. Then in the OnSubmit Before Email code box I'd have something like:
Also to get the data saved into the database you need to 'implode' the array. If you don't use ChronoForms to do this for you then you need to do it manually. It's probably simplest to do this by creating a second variable.
So, all of this is possible but you need to track the work-flow through and make sure that you have the 'right' versions of the results in each place.
Bob
I've lost track of the threads here :-(
I don't have a good answer to Q1; it might be possible to do something with a Flash uploaded to show a progress spinner (Fredrik [nml375] had a thread on this a while back), but ChronoForms can't process the files until they are uploaded so there's no easy answer to that.
You can set the option values to something more meaningful - if so then you need to track that through and make corresponding changes in the attachment code.
Personally I tend to make the code a little more complex and to look up values after the form is submitted. So, for example I'd keep check_0, check_1 as the values in the Form HTML. Then in the OnSubmit Before Email code box I'd have something like:
<?php
$check0_values = array(
'check_0' => 'Bananas',
'check_1' => 'Grapefruit',
'check_2' => 'Watermelon'
);
$check0 = JRequest::getVar('check0', array(), 'post', 'array');
foreach ( $check0_values as $k => $v ) {
if ( in_array($k, $check0 ) {
JRequest::setVar($k.'_value', $check0_values['$k']);
} else {
JRequest::setVar($k.'_value', '');
}
}
?>
I can then put {check_0_value}, {check_1_value}, . . .into the Email template and it will show 'Bananas, Grapefruit, etc.Also to get the data saved into the database you need to 'implode' the array. If you don't use ChronoForms to do this for you then you need to do it manually. It's probably simplest to do this by creating a second variable.
<?php
$check0 = JRequest::getVar('check0', array(), 'post', 'array');
$check0_string = implode(',', $check0);
JRequest:;setVar('check0_string', $check0_string);
?>
The requires you to rename the database column to check0_string (or some other name of your choice).So, all of this is possible but you need to track the work-flow through and make sure that you have the 'right' versions of the results in each place.
Bob
Hi,
As for Q1, the project I worked on was for a file upload, which might not apply here.
However, there are still a few tricks you could use, with or without Javascript.
You would probably be best off using javascript, as this allows you to warn your visitor of leaving or closing the page before the processing was completed. The mootools js-library provided by Joomla provides most of the bits'n'pieces for the actual sending of the form; see this for a few examples: http://demos111.mootools.net/Ajax.Form
Depending on your hosting environment, you might also be able to schedule a cronjob or background task, though you won't be able to use ChronoForm's email handler in this case.
/Fredrik
As for Q1, the project I worked on was for a file upload, which might not apply here.
However, there are still a few tricks you could use, with or without Javascript.
You would probably be best off using javascript, as this allows you to warn your visitor of leaving or closing the page before the processing was completed. The mootools js-library provided by Joomla provides most of the bits'n'pieces for the actual sending of the form; see this for a few examples: http://demos111.mootools.net/Ajax.Form
Depending on your hosting environment, you might also be able to schedule a cronjob or background task, though you won't be able to use ChronoForm's email handler in this case.
/Fredrik
Hi,
I am trying to do the same thing in V4 of Chronoforms - does the code here still work? ( I am having some difficulties)
I created a thread here: http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=86753 but did not get an answer then found this one.
I am using Joomla 2.5.7
Any help appreciated.
CHRIS
I am trying to do the same thing in V4 of Chronoforms - does the code here still work? ( I am having some difficulties)
I created a thread here: http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=86753 but did not get an answer then found this one.
I am using Joomla 2.5.7
Any help appreciated.
CHRIS
This topic is locked and no more replies can be posted.