We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10226
    • 412 Posts
    I guess I am loosing my ninja search skills... Long ago ( about three years ) I had a contact form that used eForm and I had multiple topics, and based on the topic, it determined who the email was sent to. It also hid the email addresses from the public.

    I looked around for a while and couldn’t find what I was looking for. If anyone knows what post this was or has done this and would like to share the code I would appreciated it.

    Thanks!
      • 27482
      • 9 Posts
      yes please. this is exactly what I need.

      I’m a new modx user - and a rookie php hacker - but I found the place in the eForms snippet that states:
      // eForm Params
         'vericode' => isset($vericode)? $vericode:"",
         'formid' => isset($formid)? $formid:"",
         'from' => isset($from)? $from:$modx->config['emailsender'],
         'fromname' => isset($fromname)? $fromname:$modx->config['site_name'],
         'to' => isset($to)? $to:"[email protected]",
      


      I would like to be able to send the email to the admin lady, the webmaster, the board of directors, etc. based on a selection that the user makes.

      How do I put conditionals in the
      'to' => isset($to)? $to:"[email protected]",
      section that would allow me to send to different addresses based on conditions???


      thanks

        • 33337
        • 3,975 Posts
        Zaigham (aka zi) Reply #3, 16 years ago
        From the eForm docs:

        &mailselector (Optional)
        Sets the name of the form field to use as a selector to select a single email from the comma (,) delimited emails assigned the &toparameter. This selector field will act like a numeric index to select an email. It will start at 1 for the first email and ends at N for the last email in the list.

        For example: &to =`[email protected],[email protected],[email protected]` &mailselector=`topic`

        On the web form the topic fields is actually a dropdown menu. when the user selects a topic from the list the value 1,2 or 3 will be sent to eForm which will then be used to select one of the three emails assigned to the &toparameter. This email address will be the address used to send the email to.
          Zaigham R - MODX Professional | Skype | Email | Twitter

          Digging the interwebs for #MODX gems and bringing it to you. modx.link
          • 27482
          • 9 Posts
          RTFM... I love it... rolleyes


          Thanks!!

            • 27482
            • 9 Posts
            ummm...

            I think I’ve stumbled on something here - can someone confirm for me?

            I’m using eForm (Snippets) - 1.4.4.6

            If I’m setting up various contact forms, do I need to make copies of the eForm snippet and make my changes there??

            Or do I just keep one eForm, and my changes just added when I call my eForm? (this is sounding pretty obvious now that I’m typing it out...)

            For example, my contact form calls:
            [!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[(emailsender)]` &ccsender=`1` &tpl=`ContactForm` &report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`ContactStyles` &gotoid=`46` !]

            The form I was trying to setup to send to different users, would just be called like this;
            [!eForm? &formid=`SignUpForm` &subject=`[+subject+]` &to=`[(emailsender)]` &ccsender=`1` &tpl=`SignUpForm` &report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`ContactStyles` &gotoid=`46` &to =`[email protected],[email protected],[email protected]` &mailselector=`topic`!]


            I was creating a new form (probably still needed), a new email report (probably still needed), and also copying the entire eForm snippet, renaming it, and making my changes to the snippet itself... (probably not needed - just call using paramaters)..



            Are my new observations correct?

            embarrassed
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              You can use as many forms as you want; eForm uses the formId (which must match either the ID attribute of the form or a hidden field with the same value) to differentiate between the forms. You can use the same report tpl if the fields are the same.

              If all you want to do is have the report mailed to different addresses depending on the subject, you can use a select drop-down for the subject, and use a custom function to change the "to" address using the &eFormOnBeforeMailSent event. The function will have the $fields array available, and can simply change the $fields[’to’] element’s value to correspond to the $fields[’subject’] value.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org