Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

can UserForms send email depending on a dropdown choice ?


Go to End
Reply

11 Posts   1967 Views

Avatar
qlex

18 May 2011 at 10:18pm Community Member, 68 Posts

I'm using UserForms on a couple of SS_powered website and I must say its very practical and allows me to quickly create a good contact form that allow visitors of the website to send email to my customer.

Would it be possible to add a condition to a dropdown that would direct a given message to a specified email address ?

I.e.
if visitor selects option "a" in dropdown in contact form, email is sent to "email address x"
if visitor selects option "b", email is sent to "email address y" and so on ?

regards,
Qlex

Avatar
Zauberfisch

20 May 2011 at 12:59am (Last edited: 20 May 2011 1:01am), Community Member, 30 Posts

I once needed exactly the same, make userforms send a email to a email address depending on what topic is selected in the dropdown
I forked userforms
even have an open pull request, but I don't mind willr not taking it, my code sucks :D
inline CSS + JS, had no other choice at that time, was in a hurry and had no time for clean coding

here is a link: https://github.com/Zauberfisch/silverstripe-userforms
I hope that helps

when I get time, I rewrite it in a proper way and look to it that it gets accepted, but no time for that at the moment :/

// Edit: if you have any questions, just hop on IRC, and stay a bit longer, it often takes me a bit till I check for new messages :P

Avatar
qlex

20 May 2011 at 1:03am Community Member, 68 Posts

Great!
I will give it a shot as soon as I get the chance. Should be tomorrow afternoon.

Qlex

Avatar
qlex

20 May 2011 at 8:34am Community Member, 68 Posts

Zauberfisch: i did a test but havent noticed anything 'extra' that would allow me to create a dropdown that would then be used to redirect messages to a precise email receipients ?
any hints ?

Avatar
Zauberfisch

23 May 2011 at 11:26pm Community Member, 30 Posts

create a userforms page.
create a dropdown field.
add some values to the dropdown field.
You will notice there are now 2 fields, 1 is the label, the 2nd one the value (in our case the email should be the value)
save the page
go to the tab where you can select emails that get sent onsubmit.
there you have an option to send it to a email adress or you can select one of the fields from the dropdown.
in this dropdown you should see the name of the dropdown that you created in the form, select that, and save it.

if a user now uses the form and submits it, the email will be sent to the email adress selected.

NOTE: as said its not nice coded, and not fully tested yet, it might happen that you run into errors, for example if the user sends the form but has no email selected in the dropdown. (i just made the dropdown required to go around that).

Avatar
qlex

23 May 2011 at 11:50pm Community Member, 68 Posts

Great, thanx for this "tutorial". It works! Will test it further and will deploy for my client tomorrow.

Qlex

Avatar
qlex

31 May 2011 at 9:10am Community Member, 68 Posts

Zauberfisch: i deployed for my client and it looks promising.
Just one question, is it possible to give 2 values for 1 option ? in other words, so that when visitor of website chooses one option, message is sent to two email receipients ?

Avatar
netnerd85

6 February 2012 at 11:32pm Community Member, 42 Posts

Awesome update, thank you very much!

Go to Top