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

    Can anyone help with this?

    I’ve amended one of our standard forms on our website to included a drop down so you can select the relevant category. Based on the category you select, the form should be emailed to the relevant person/s.

    The HTML looks like as follows:

    [[$header]]
    <div class="third_nav">
    [[Wayfinder? &startId=`6` &level=`1` &outerTpl=`third_nav_ul` &rowTpl=`third_nav_tpl` &hideSubMenus=`TRUE` &hereClass=`current` ]]
    </div>
    <div class="main-container">
    <h1>[[*longtitle]]</h1>
    <div class="content contact">
    [[*content]]
    [[!FormIt?
    &hooks=`groupSelector,email,redirect`
    &emailTpl=`contact-form`
    &emailTo=`[[+emailAddresses]]`
    &emailSubject=`Supplier Introduction`
    &redirectTo=`186`
    &validate=`name:required,
    email:email:required,
    number:required,
    text:required:stripTags`
    ]]
    [[!+fi.error.error_message:notempty=`<p>[[!+fi.error.error_message]]</p>`]]

    <form action="[[~[[*id]]]]" method="post" class="form">
    <form action="" method="post" class=”f24form” id=”contact-form” name=”contact-form”
    F24Name=”contact-form”>
    <input type="hidden" name="nospam:blank" value="" />

    <label for="name">
    Full Name:
    [[+fi.error.name]]
    </label>
    <input type="text" name="name" id="name" value="[[+fi.name]]" />
    <br class="clr" />

    <label for="organisation">
    Organisation Name:
    [[+fi.error.organisation]]
    </label>
    <input type="text" name="organisation" id="organisation" value="[[+fi.organisation]]" />
    <br class="clr" />

    <label for="address">
    Address:
    [[+fi.error.address]]
    </label>
    <textarea name="address" id="address" >[[+fi.address]]</textarea>
    <br class="clr" />

    <label for="city">
    City:
    [[+fi.error.city]]
    </label>
    <input class="width150" type="text" name="city" id="city" value="[[+fi.city]]" />
    <div class="clr"></div>

    <label for="country">
    Country:
    [[+fi.error.country]]
    </label>
    <input class="width150" type="text" name="country" id="country" value="[[+fi.country]]" />
    <br class="clr" />

    <label for="postcodec">
    Post code:
    [[+fi.error.postcodec]]
    </label>
    <input type="text" name="postcodec" id="postcodec" value="[[+fi.postcodec]]" />
    <br class="clr" />

    <label for="number">
    Contact number:
    [[+fi.error.number]]
    </label>
    <input class="width150" type="text" name="number" id="number" value="[[+fi.number]]" />
    <br class="clr" />

    <label for="email">
    Email:
    [[+fi.error.email]]
    </label>
    <input type="text" name="email" id="email" value="[[+fi.email]]" />
    <br class="clr" />

    <label for="service">Please select the relevant Buyer</label>
    <select name="service" style="width: 308px">
    <option value="0">Please choose...</option>
    <option value="1">Supply Chain Logistics</option>
    <option value="2">Professional Business Services</option>
    <option value="3">Facilities Management Business Support</option>
    <option value="4">Landfill Construction GTE</option>
    <option value="5">Disposals</option>
    </select>
    <br class="clr" />

    <label for="text">
    Services/Supply Details:
    [[+fi.error.text]]
    </label>
    <textarea name="text" id="text" cols="55" rows="7">[[+fi.text]]</textarea>
    <br class="clr" />

    <br class="clr" />
    [[!+formit.recaptcha_html]]
    [[!+fi.error.recaptcha]]

    <br class="clear" />




    <div class="form-buttons">
    <input onClick="_gaq.push(['_trackEvent', 'Contact Forms', 'Submit', 'Supplier Introduction']);" class="button" type="submit" value="Submit" />
    </div>
    </form>
    </div>
    <div class="right-bar">
    [[$right-bar]]
    </div>
    [[$home_more]]
    [[$home_services]]
    </div>
    [[$footer]]




    //I've created a snippet call 'groupSelector' which the dropdown uses as follows://




    #$group[0] = '[email protected]; // Default group (no choice)
    $group[0] = '[email protected],[email protected]';
    $group[1] = '[email protected],[email protected]'; // Supply Chain Logistics option
    $group[2] = '[email protected],[email protected]'; // Professional Business Services option
    $group[3] = '[email protected],[email protected]'; // Facilities Management Business Support option
    $group[4] = '[email protected],[email protected],[email protected]'; // Landfill Construction GTE option
    $group[5] = '[email protected],[email protected]'; // Disposals option

    $userChoice = $hook->getValue('service');
    $hook->setValue('emailAddresses',$group[$userChoice]);
    return true;


    Unfortunately nothing happens when the submit button is clicked.

    Can anyone see what I’ve missed?

    Cheers

    Robin

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

    • Did you look at the dynamic recipient information here: http://rtfm.modx.com/extras/revo/formit/formit.hooks/formit.hooks.email

      You shouldn't need to use a custom hook to accomplish this goal, which could be the source of your problem.
        Patrick | Server Wrangler
        About Me: Website | TweetsMODX Hosting
        • 19872
        • 1,078 Posts
        Hey Patrick: Thanks for this tip. Am in the process of getting ready to tackle this very topic with one of my formit forms.
        • discuss.answer
          • 48748
          • 2 Posts
          Issue resolved by amending snippet as follows:

          $group[0] = '[email protected]'; // Default group (no choice)
          $group[1] = '[email protected],[email protected]'; // Supply Chain Logistics option
          $group[2] = '[email protected],[email protected]'; // Professional Business Services option
          $group[3] = '[email protected],[email protected]'; // Facilities Management Business Support option
          $group[4] = '[email protected],[email protected],[email protected]'; // Landfill Construction GTE option
          $group[5] = '[email protected],[email protected]'; // Disposals option

          $userChoice = isset($_POST['service']) ? (int) $_POST['service'] : 0;
          return isset($group[$userChoice]) ? $group[$userChoice] : $group[0];

          #$userChoice = $hook->getValue('service');
          #$hook->setValue('emailAddresses',$group[$userChoice]);
          #return true;