Forums

Define recipient with a dropdown menu?

CharlieMon 18 Jan, 2012
I've seen lots of posts that ALMOST showed what to do, but if there is a FAQ or other tutorial on this, I'm sorry for missing it.

I have created a dropdown menu where the user selects the topic. Based on what they select, the submit would fire off an email to a specific recipient. The recipient is determined by what they selected in that dropdown menu.

So, a dropdown list of:

Favorite color:
green
blue
yellow

If they select "green" it goes to Joe, if they select "blue" it goes to Sue, etc. If you can point me to instructions on this, or any other help, I would certainly appreciate it.

Thanks!
GreyHead 19 Jan, 2012
Hi CharlieMon,

Which version of ChronoForms are you using? You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6.

Bob
CharlieMon 19 Jan, 2012
Ack, sorry, should have mentioned that: 4.0 RC3.0 on Joomla 1.7. Thanks!
CharlieMon 23 Jan, 2012
We're close...I read through that post last week, but I'm getting this error:

You must provide at least one recipient email address.

If I put an email address in the static "to" field, the code from this post seems to be ignored. So, how do I use this nice code which dynamically creates the recipient? I must be missing something fundamental.
Max_admin 23 Jan, 2012
Hi CharlieMon,

Can you send an email with a "Dynamic to" (no static) fine ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
CharlieMon 23 Jan, 2012
If I leave the static "to" field blank and enter an email address in the dynamic "to" field, I get the same error message.

charlie
GreyHead 24 Jan, 2012
Hi CharlieMon,

Please post here the code and settings you are using.

You can't use an email address in a Dynamic box - only an input name will work there.

Bob
CharlieMon 24 Jan, 2012
Bob - thanks for the assistance. If I can get this to work, I'll have a nice fat project to do, it all comes down to getting this working. If we can, then many beers are coming your way 🙂

I have tried the following in the dynamic "to" field, none worked:

a real email address
emails
$emails
recipient
$recipient

but it only seems to work with an email address in the static "to" field, which isn't what we're after. Here is the code I'm using in the "code" tab:

custom code - onsubmit:
mode - controller
action label - onsubmit

<?php
$recipient = JRequest::getString('recipients', 'em1', 'post');
$emails = array (
  'em1' => 'xx@gmail.com',
  'em2' => 'charlie@xx.net',
  'em3' => 'info@xx.com'
);
$form->data['email_to_use'] = $emails[$recipient];
?>


I'm using "xx" above to hide the actual email addresses I'm using. Then, in the "emails" tab, I have:

Email - onsubmit
Enabled - yes
Action label - onsubmit
Static to - blank
Dynamic to - see above, tried various things here

Again, thanks, this will be awesome once it's working.

charlie
GreyHead 24 Jan, 2012
Hi CharlieMon,

A quick answer as it's nearly midnight here. If you are putting the email into the 'email_to_use' form data entry here:
$form->data['email_to_use'] = $emails[$recipient];
Then you need email_to_use in the Dynamic To box (with no quotes or brackets).

Bob
CharlieMon 24 Jan, 2012
Bob - just sent you a beer 🙂

Well, sorry, I still get the same error message. What would be easiest -- I can create a super admin account, or I can send you screenshots of all this.

I'd really like to get this working, it would make me look like a rock start 🙂
GreyHead 25 Jan, 2012
Hi CharlieMon,

Thanks for the 'beer', much appreciated.

Please check that the action sequence is correct. The Custom Code action needs to be before the Email action.

By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

Bob
CharlieMon 25 Jan, 2012
Thanks...PM has been sent.
GreyHead 25 Jan, 2012
Hi CharlieMon,

Seems to be working OK now. I removed all the other entries from the Dynamic Tab. Those boxes only take input names.

Bob
CharlieMon 25 Jan, 2012
I'm still getting the same error:

You must provide at least one recipient email address.
GreyHead 25 Jan, 2012
Hi CharlieMon,

It's a bit weird. If I put my address in the Static CC box it sends OK.

Solved . . . I made a copy and switched to the Advanced Wizard. The Custom Code on-submit in the Easy Wizard runs after the Emails so putting the code there has no effect. The other Custom code box should be OK.

Bob
CharlieMon 25 Jan, 2012
This just made my day...week.

Yep, I have tested all 3 email addresses on the new form, it all works great.

ChronoEngine rocks! I'm putting together a reward right now. Thanks again!
CharlieMon 25 Jan, 2012
The form you helped with had 2 basic fields, so now I'm going in and adding the rest of the fields for the form. It's all going fine, but where is the code that defines "em1" etc. into valid email addresses?

BTW, purchased a 3-site license today, 1 for this build site, then we'll use 1 of the others when the site goes live.

And, another beer is coming later today.
GreyHead 26 Jan, 2012
Hi CharlieMon,

It's in the Custom Code action, click the middle 'spanner' icon to open the configuration dialogue.

Bob
CharlieMon 26 Jan, 2012
Got it, thanks. I was hesitant to mess with the Wizard, as there were red warnings about resetting the form's events. Sure, enough, had to rebuild a few things, but it didn't take long.

I think we're good on this one -- thanks for all the very excellent support!
GreyHead 26 Jan, 2012
Hi CharlieMon,

I almost always use the Advanced Wizard. The Easy Wizard is fine when you are starting out but it does add almost every action. You can go from Easy to Advanced with no problem - but not from Advanced back to Easy.

Bob
This topic is locked and no more replies can be posted.