Jump to:

10844 Posts in 2515 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » can UserForms send email depending on a dropdown choice ?

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 1710 Views
  • qlex
    Avatar
    Community Member
    68 Posts

    can UserForms send email depending on a dropdown choice ? Link to this post

    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

  • Zauberfisch
    Avatar
    Community Member
    30 Posts

    Re: can UserForms send email depending on a dropdown choice ? Link to this post

    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
    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

  • qlex
    Avatar
    Community Member
    68 Posts

    Re: can UserForms send email depending on a dropdown choice ? Link to this post

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

    Qlex

  • qlex
    Avatar
    Community Member
    68 Posts

    Re: can UserForms send email depending on a dropdown choice ? Link to this post

    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 ?

  • Zauberfisch
    Avatar
    Community Member
    30 Posts

    Re: can UserForms send email depending on a dropdown choice ? Link to this post

    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).

  • qlex
    Avatar
    Community Member
    68 Posts

    Re: can UserForms send email depending on a dropdown choice ? Link to this post

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

    Qlex

  • qlex
    Avatar
    Community Member
    68 Posts

    Re: can UserForms send email depending on a dropdown choice ? Link to this post

    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 ?

  • netnerd85
    Avatar
    Community Member
    42 Posts

    Re: can UserForms send email depending on a dropdown choice ? Link to this post

    Awesome update, thank you very much!

    1710 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.