We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37449
    • 57 Posts
    Hi FormIt guru's!

    Has anyone figured out a way to hide the email address of a <select> element?

    What I mean is, if I have a list of people that can be contacted in the form:
        <select name="refer" id="refer">
        <option value="null">Select One</option>
        <option value="[email protected]">Chairman</option>
        <option value="[email protected]">Vice Chairman</option>
        <option value="[email protected]">Treasurer</option>
        <option value="[email protected]">>Instruments</option>
        </select>
    


    And I use the
    [[+addressTo]]
    and
    [[!+fi.addressTo:FormItIsSelected=``]]
    to dynamically select the email address, this works fine.

    However, the email addresses are visible in the HTML and I would like to hide them.

    I have tried:
    <option value="2" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]] ...
    

    but this does not work.

    I am playing with using a custom hook using the examples given at http://rtfm.modx.com/display/ADDON/FormIt.Examples.Custom+Hook but I can't figure out how to either pass the parameter for the selected option, or read that some other way...

    Has anyone figured this out, that could point me in the right direction?

    Thanks in advance
    Daz


    Revo 2.2.0.pl
    FormIt 2.0.3pl
    PHP 5.3.0
    Running WAMP on Win 7 [ed. note: astrodaz last edited this post 12 years, 1 month ago.]
      formerly sumodaz on here!
      • 37449
      • 57 Posts
      I ran this past a friend of mine, who is conversant in PHP, and this is how he solved it...

      First, on the contact page, a call to a custom snippet, and an amendment to the FormIt parameter for the emailTo field:

      [[!MyFormIt]]
      [[!FormIt?
         &hooks=`spam,email,redirect`
         &emailTo=`[[+emailto]]`
         &redirectTo=`1`
         &validate=`
            name:required,
            email:email:required,
            subject:required,
            text:required:striptags`
         &validationErrorMessage=`<h4>Please correct the errors in <span class="red">red</span></h4>`]]
      


      Note the cunningly name custom snippet - MyFormIt !!

      Here is the code in the snippet:

      <?php
      if ($_POST['addressTo'] == 1) { $_POST['emailto']= "[email protected]"; }
      if ($_POST['addressTo'] == 2) { $_POST['emailto']= "[email protected]"; }
      
      


      Finally, the change to the <select> element is:

      <option value="1" [[!+fi.addressTo:FormItIsSelected=`1`]]>Chairman</option>
      



      And bingo! The email sends, but the address is not in the rendered HTML!

      :D
        formerly sumodaz on here!
        • 38494
        • 13 Posts
        perfect, just what i needed before i even began to look

        guess eventually the new snippet should be modified so that you can set the emails from the snippet call instead of editing the snippet [ed. note: kn00tcn last edited this post 12 years, 1 month ago.]