Hey,
I am using ChronoFormsV4.
I am using the code where you HIDE a recipients email while letting a person choose from a list of people to send to.
Learning V4 - it's been cool. But a little slow (no one has ever mistaken me for a programmer)
In the FORM WIZARD:
1 - I have a "Custom Element"
2 - In that "Custom Element" I have this:
3 - In the ONSUBMIT ACTIONS - I have a "Custom Code" action that says this:
4 - Under the EMAIL ACTION (Dynamic To) I have this:
But it's not working. Any thoughts? Thanks!
I am using ChronoFormsV4.
I am using the code where you HIDE a recipients email while letting a person choose from a list of people to send to.
Learning V4 - it's been cool. But a little slow (no one has ever mistaken me for a programmer)
In the FORM WIZARD:
1 - I have a "Custom Element"
2 - In that "Custom Element" I have this:
<select name="recipients">
<option value="Tom1">Tom 1</option>
<option value="TAG2">Tag 2</option>
<option value="Thomas3">Thomas 3</option>
</select>
3 - In the ONSUBMIT ACTIONS - I have a "Custom Code" action that says this:
<?php
$recipient = JRequest::getString('recipients', '', 'post');
$emails = array (
'Tom1' => 'me@domain1.com',
'TAG2' => 'me@domain2.com',
'Thomas3' => 'me@domain3.com',
);
$email_to_use = $emails[$recipient];
JRequest::setVar('email_to_use', $email_to_use);
?>
4 - Under the EMAIL ACTION (Dynamic To) I have this:
email_to_use
But it's not working. Any thoughts? Thanks!
Hi cb1,
You are way ahead of me in experimenting with CFv4. I'll add this to my to-do list and see if I can work it out.
Bob
You are way ahead of me in experimenting with CFv4. I'll add this to my to-do list and see if I can work it out.
Bob
Hi cb1,
I think I have this working - just waiting for the Email to confirm (now received OK).
a) I used a Select Box element in the Form Preview with the name & id set to recipients and the options:
b) In the OnSubmit event I have a Custom Code action with mode = controller and this code:
c) Also in the OnSubmit event I have an Email action with the Dynamic To set to email_to_use; it is enabled and has standard Static values for Subject, From Name and From Email.
Bob
I think I have this working - just waiting for the Email to confirm (now received OK).
a) I used a Select Box element in the Form Preview with the name & id set to recipients and the options:
em1=This address
em2=That address
em3=The other address
b) In the OnSubmit event I have a Custom Code action with mode = controller and this code:
<?php
$recipient = JRequest::getString('recipients', 'em1', 'post');
$emails = array (
'em1' => 'bob@example.com',
'em2' => 'info@example.net',
'em3' => 'admin@example.com'
);
$form->data['email_to_use'] = $emails[$recipient];
?>
c) Also in the OnSubmit event I have an Email action with the Dynamic To set to email_to_use; it is enabled and has standard Static values for Subject, From Name and From Email.
Bob
Hello,
For the coding in part b, I have a question about two parts of coding you have inserted.
Your coding:
getString('recipients', 'em1', 'post'); - I have several email addresses to include so do I have to put all email addresses where em1 is?
$form->data['email_to_use']= $emails[$recipient];
Do I have to include my email addresses all here aswell?
Thanks!
For the coding in part b, I have a question about two parts of coding you have inserted.
Your coding:
getString('recipients', 'em1', 'post'); - I have several email addresses to include so do I have to put all email addresses where em1 is?
$form->data['email_to_use']= $emails[$recipient];
Do I have to include my email addresses all here aswell?
Thanks!
Hi MTP,
This line
When you say you have 'several email addresses': are you saying that you want to send the same email to several addreses at the same time?
This line
Bob
This line
$recipient = JRequest::getString('recipients', 'em1', 'post');
gets the values submitted from the form; 'em1' is a default setting so in this case it says "If nothing is returned from the form use the em1 email address to send this to".When you say you have 'several email addresses': are you saying that you want to send the same email to several addreses at the same time?
This line
$form->data['email_to_use']= $emails[$recipient];
is looking up the emails to use from the array set up earlier in the code. You shouldn't need to change this line.Bob
Hi,
Thanks for the reply and for the help on this.
When I say I have several email addresses I mean I want to send a form to email address selected in a drop down box. - this is why I am a little confused on the em1 coding.
So where it says em1 shall I put all my email addresses that I have in that space?
Thanks!!
Thanks for the reply and for the help on this.
When I say I have several email addresses I mean I want to send a form to email address selected in a drop down box. - this is why I am a little confused on the em1 coding.
So where it says em1 shall I put all my email addresses that I have in that space?
Thanks!!
Hi MTP,
No, absolutely not.
Your emails go here
Bob
So where it says em1 shall I put all my email addresses that I have in that space?
No, absolutely not.
Your emails go here
$emails = array (
'em1' => 'bob@example.com',
'em2' => 'info@example.net',
'em3' => 'admin@example.com'
);
Bob
Thank you for your help on this I have sent the form and it sends perfectly with no errors.
The only issue now is that I have taken the {} away from the {input_custom_15} fields and they are still showing as this on the form:
Name: input_custom_15
Email: input_custom_14
Is there something that I am doing wrong.
Sorry to be asking so many questions by the way.
Thanks!!!
The only issue now is that I have taken the {} away from the {input_custom_15} fields and they are still showing as this on the form:
Name: input_custom_15
Email: input_custom_14
Is there something that I am doing wrong.
Sorry to be asking so many questions by the way.
Thanks!!!
Hi MTP,
Please post a screen shot of the page where you have these settings.
Bob
Please post a screen shot of the page where you have these settings.
Bob
Hi,
Thanks for the reply. Here is a screenshot of the where the coding is.
Thanks again
Thanks for the reply. Here is a screenshot of the where the coding is.
Thanks again
Hi MTP,
My apologies, you do need the curly brackets in the Template. It's the Dynamic tab that doesn't use them.
Bob
My apologies, you do need the curly brackets in the Template. It's the Dynamic tab that doesn't use them.
Bob
Hi,
Thanks for the reply.
I have added the curly brackets back in and it still doesnt work as I still get the Name: {input_custom_15} on the template.
Is there something else that I am doing wrong?
Sorry for asking alot of questions - and because you have helped me alot with my questions I have bought you a beer.
Thanks again!
Thanks for the reply.
I have added the curly brackets back in and it still doesnt work as I still get the Name: {input_custom_15} on the template.
Is there something else that I am doing wrong?
Sorry for asking alot of questions - and because you have helped me alot with my questions I have bought you a beer.
Thanks again!
Hi MTP,
Thanks for the beer :-)
Do you have an input_custom_15 input in your form?
Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Bob
Thanks for the beer :-)
Do you have an input_custom_15 input in your form?
Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Bob
Hi MTP,
You've got a sightly hybrid form here, it looks as though it's been edited partly as custom code and partly in the Wizard. I'll try to tidy it up and send a copy back.
Just to confirm you want the Name & Email to be included but not editable?
Bob
You've got a sightly hybrid form here, it looks as though it's been edited partly as custom code and partly in the Wizard. I'll try to tidy it up and send a copy back.
Just to confirm you want the Name & Email to be included but not editable?
Bob
Hello,
Thank you for having a look at the form.
Yes please, I would like the Name and Email of the person who is logged on to appear on the form but I dont want it editable.
Also, if it is no trouble, would you mind looking at this other issue I have with the form?
When I submit the form, the template displays a 'to be authorised by' field and then would like the name of the person selected to appear but instead I get the email address of the person selected instead. Is there a way of making it into a name?
If it is too much trouble then do not worry.
Sorry about the questions I keep asking.
Thanks!
Thank you for having a look at the form.
Yes please, I would like the Name and Email of the person who is logged on to appear on the form but I dont want it editable.
Also, if it is no trouble, would you mind looking at this other issue I have with the form?
When I submit the form, the template displays a 'to be authorised by' field and then would like the name of the person selected to appear but instead I get the email address of the person selected instead. Is there a way of making it into a name?
If it is too much trouble then do not worry.
Sorry about the questions I keep asking.
Thanks!
Hi MTP,
Have you checked the version of the form I sent back to you yesterday?
Bob
Have you checked the version of the form I sent back to you yesterday?
Bob
Hi,
Thanks for the reply. No I havent had a look at the form you sent back yet but I will have a look and will let you know.
Thanks again!
Thanks for the reply. No I havent had a look at the form you sent back yet but I will have a look and will let you know.
Thanks again!
Hello,
Thank you for the code that I was looking for... 😀
I am still struggling with it. The e-mail get send, which is a step forward... but despite I have configured 3 different addresses, all the e-mails got send to the same one 🙄 I have to admit that I am not a real freak of coding.
Please see below the codes I have in the custom code on the on submit section
And also what I have in the options of the select box :
Any advice ? 😀
Thank you.
Thank you for the code that I was looking for... 😀
I am still struggling with it. The e-mail get send, which is a step forward... but despite I have configured 3 different addresses, all the e-mails got send to the same one 🙄 I have to admit that I am not a real freak of coding.
Please see below the codes I have in the custom code on the on submit section
<?php
$recipient = JRequest::getString('recipients', 'em1', 'post');
$emails = array (
'suisse' => 'manes@XXX.com',
'france' => 'manes@XXX.net',
'belgique' => 'manes@XXX.ch'
);
$form->data['email_to_use'] = $emails[$recipient];
?>
And also what I have in the options of the select box :
suisse=suisse
france=france
belgique=belgique
Any advice ? 😀
Thank you.
Hi Manes,
Which one do they get sent to?
Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Bob
Which one do they get sent to?
Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Bob
HI Bob,
Thank you for the proposal. I attach the backup of my form here.
Looking forward for your lights !
Manes.
Thank you for the proposal. I attach the backup of my form here.
Looking forward for your lights !
Manes.
Hi Manes,
The options in the select box aren't what you thought they were:
You need to change them, or change the code to match these.
Bob
The options in the select box aren't what you thought they were:
em1=suisse
em2=france
em3=belgique
You need to change them, or change the code to match these.
Bob
Hi Bob,
Thanks for that. And sorry I should have explained that I slightly changed the code since my comment.
In the backup attached in my previous poste the codes are :
and
Which seems to match...
The thing is I am still receiving e-mail only to the address of em1...
Can you take a look at the backup and let me know if you see something else ?
Thank you.
Manes
Thanks for that. And sorry I should have explained that I slightly changed the code since my comment.
In the backup attached in my previous poste the codes are :
em1=suisse
em2=france
em3=belgique
and
<?php
$recipient = JRequest::getString('recipients', 'em1', 'post');
$emails = array (
'em1' => 'manes@mac.com',
'em2' => 'manes@mylennium.net',
'em3' => 'chanteloup@bluewin.ch'
);
$form->data['email_to_use'] = $emails[$recipient];
?>
Which seems to match...
The thing is I am still receiving e-mail only to the address of em1...
Can you take a look at the backup and let me know if you see something else ?
Thank you.
Manes
Hi Manes,
Your drop-down name is country (not recipient) so this line
Bob
Your drop-down name is country (not recipient) so this line
$recipient = JRequest::getString('recipients', 'em1', 'post');
needs to be$recipient = JRequest::getString('country', 'em1', 'post');
Bob
Hi Bob,
Thank you for your answer. I recieved e-mails from the form, so I guess you gave a try!
Thank you for showing light to my obviousely closed eyes ! I feel stupid 😲
Manes
Thank you for your answer. I recieved e-mails from the form, so I guess you gave a try!
Thank you for showing light to my obviousely closed eyes ! I feel stupid 😲
Manes
I am using this code:
<?php
$recipient = JRequest::getString('clinic', '', 'post');
$emails = array (
'em1' => [email]'email@domain.com.au[/email]',Â
'em2' => [email]'email@domain.com[/email]',
'em3' => [email]'email@seconddomain.com[/email]'
);
$email_to_use = $emails[$recipient];
$form->data['email_to_use'] = $email_to_use;
?>
And it is sending emails as I want them sent however because I am getting an error message above my HTML Thank You message saying:
Language string failed to load: invalid_address: em3
I think this is because the Dynamic To is set to email_to_use and it isn't an email address. So what I want to know is can I switch this error message off even though it is a correct error message?
<?php
$recipient = JRequest::getString('clinic', '', 'post');
$emails = array (
'em1' => [email]'email@domain.com.au[/email]',Â
'em2' => [email]'email@domain.com[/email]',
'em3' => [email]'email@seconddomain.com[/email]'
);
$email_to_use = $emails[$recipient];
$form->data['email_to_use'] = $email_to_use;
?>
And it is sending emails as I want them sent however because I am getting an error message above my HTML Thank You message saying:
Language string failed to load: invalid_address: em3
I think this is because the Dynamic To is set to email_to_use and it isn't an email address. So what I want to know is can I switch this error message off even though it is a correct error message?
Hi PaulT,
I'm not sure why 'em3' is showing up in the error message??
The message itself is a Joomla! bug. More info from this post and a code hack fix in this one.
Bob
I'm not sure why 'em3' is showing up in the error message??
The message itself is a Joomla! bug. More info from this post and a code hack fix in this one.
Bob
Thanks Bob,
I seem to have handled it for me by creating a redirect page instead of having a Show Thanks Message.
I seem to have handled it for me by creating a redirect page instead of having a Show Thanks Message.
I'm trying to do this as well. So far, it's still sending all emails to my static email address.
Are you supposed to put actual email addresses here, or does it not really matter what goes in place of "This address"?
em1=This address
em2=That address
em3=The other address
Are you supposed to put actual email addresses here, or does it not really matter what goes in place of "This address"?
Hi krishunt,
Yes, you are supposed to use actual email addresses to send your emails.
Bob
Yes, you are supposed to use actual email addresses to send your emails.
Bob
Well, when you say it like that, it sounds like a stupid question. 🙂 But the code in question is in the Select Box element:
You have already listed the actual email addresses in the Custom Code action:
Is it necessary to repeat them in the Select Box element? If so, why didn't you do that in your example?
em1=This address
em2=That address
em3=The other address
You have already listed the actual email addresses in the Custom Code action:
<?php
$recipient = JRequest::getString('recipients', 'em1', 'post');
$emails = array (
 'em1' => 'bob@example.com',
 'em2' => 'info@example.net',
 'em3' => 'admin@example.com'
);
$form->data['email_to_use'] = $emails[$recipient];
?>
Is it necessary to repeat them in the Select Box element? If so, why didn't you do that in your example?
Hi krishunt,
My apologies, unless I recognise the thread I just reply to the post in front of me without looking back to find the context.
No the options should have values in them to let the user choose the recipent, not the emails themselves. For example:
Bob
My apologies, unless I recognise the thread I just reply to the post in front of me without looking back to find the context.
No the options should have values in them to let the user choose the recipent, not the emails themselves. For example:
em1=Bob
em2=John
em3=Admin
orem1=East Coast
em2=West Coast
em3=In between
Bob
Thanks very much; it's working for me now. Only thing is, in addition to sending an email to the dynamic address, it's also sending it to the required static address. Is there any way around this, or do I just need to set the static address to a fake address?
This topic is locked and no more replies can be posted.