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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

can UserForms send email depending on a dropdown choice ?


Go to End


11 Posts   4606 Views

Avatar
qlex

Community Member, 68 Posts

18 May 2011 at 10:18pm

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

Community Member, 30 Posts

20 May 2011 at 12:59am

Edited: 20/05/2011 1:01am

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

Community Member, 68 Posts

20 May 2011 at 1:03am

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

Qlex

Avatar
qlex

Community Member, 68 Posts

20 May 2011 at 8:34am

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

Community Member, 30 Posts

23 May 2011 at 11:26pm

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

Community Member, 68 Posts

23 May 2011 at 11:50pm

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

Qlex

Avatar
qlex

Community Member, 68 Posts

31 May 2011 at 9:10am

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
jaybee

Community Member, 49 Posts

6 February 2012 at 11:32pm

Awesome update, thank you very much!

Go to Top