We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47690
    • 22 Posts
    Hi all,

    Apologies in advance if this is a stupid question--I'm afraid I'm still a newbie. smiley

    I'm in the process of dumping an existing CMS in favor of MODX, and I'm trying to do the revised site the right way, but I've run into a problem and wondered if someone could help.

    We have a "contact us" form that allows people to send messages asking for help on different topics (chosen by a <SELECT>). Based on the topic selected, the form is routed to different people in the organization.

    In our old CMS, we just did this by posting the form to a server-side PHP script, which looks up the appropriate recipient(s) in our personnel database and sends the email message.

    In our new MODX CMS, I'm thinking "the right way" means using FormIt. My problem is that I can't figure out how to do the personnel database lookup to get the appropriate email address as part of a FormIt call.

    Can someone point me in the right direction, please? If necessary, I will, of course, just use the same server-side PHP solution we have already, but I'd love to use the available MODX mechanisms if I can.

    Thanks so much!!

    This question has been answered by Jako. See the first response.

      • 3749
      • 24,544 Posts
      You might take a look at SPForm. It's not particularly customizable, but it installs a contact form automatically and will let you easily set up a list of recipients with whatever screen names you want to use. The user selects them from a drop-down list and the email addresses are never exposed. It also has lots of spam-proofing options.

      FWIW, I have never used FormIt for anything and if SPForm wouldn't do what I wanted, I'd write a custom snippet to process the form, probably using MandrillX to send the email.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 44580
        • 189 Posts
        I think that you can do this natively with Formit but I haven't exactly done what you are trying to do so you may need to experiment.

        Use a placeholder for your emailTo address in the Formit call:
        &emailTo=`[[+email]]`

        Then, in the select, something like:
        <select name="email" required value="[[!+fi.email]]">
             <option value="[email protected]" [[!+fi.email:is=`[email protected]`:then=`selected`]]>Topic1</option>
             <option value="[email protected]" [[!+fi.email:is=`[email protected]`:then=`selected`]]>Topic2</option>
             <option value="[email protected]" [[!+fi.email:is=`[email protected]`:then=`selected`]]>Topic3</option>
         </select>

        If this doesn't work, a custom hook would do the job: http://rtfm.modx.com/extras/revo/formit/formit.tutorials-and-examples/formit.examples.custom-hook
        • discuss.answer
          • 13428 ☆ A M B ☆
          • 1,031 Posts
          &emailTo=`[[+email]]`

          Don't do that for the following reason: The email form field value is not restricted to the values in the select and could be spoofed. So everyone could call your site with own POST values and set the value of the posted email field to another mail address. This way your site could be used as spam sender.

          @pitarr: If you want to use FormIt for that, you have to write two hooks, a preHook that fills a form field with the id of the user in the personnel database (could be a dropdown select too). And a hook that translates the posted id to a mail-address and fills $this->formit->config['emailTo']. This hook has to work before the email hook.

          To retreive data from the personnel database you should use xPDO. Bob has written a good start for that on http://bobsguides.com/revolution-objects.html
            • 47690
            • 22 Posts
            Wish I could mark more than one reply as the answer, because all of you had really good suggestions--thank you all *SO* much!! I chose MODX--despite pressure to go with one of the "big 3"--because it's so much cleaner a solution, but the awesome community was a big factor in my decision as well.

            @BobRay, I definitely will look at SPForm, and @Jako, I will definitely look at both prehooks and xPDO. Thank you for a wealth of extremely valuable information!