We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9266 ☆ A M B ☆
    • 77 Posts
    I am trying to use an ajax auto-complete value to us an if value post hook to determine who to send the emails to. Basically we have created a form that uses a simple ajax auto-complete. See the Form: http://excelerondesigns.com/~bristolm/index.php?id=10

    Each association has three TV's attached to them( Targeted Email Addresses) We need to have the TV's values pulled to determine where the email is routed to.

    Any Idea's?

    Here is the formit Code:
    [[!FormIt?
    &hooks=`email,redirect`
    &postHooks=`getEmailAdd`
    &emailTpl=`wo-form-tpl`
    &emailTo=`[email protected]`
    &redirectTo=`1`
    &validate=``
    ]]
    <form action="[[~[[+id]]]]" class="form-2" method="post">
    <fieldset>
    <div class="row">
    <label for="id-30">Association:<span class="required">*</span></label>
    <div class="ac-item">
    <input type="text" class="autocomplete" id="id-30" placeholder="Write the Association" data-path="[[~43]]" name="association" value="[[+association]]" />
    <div class="ac-holder"></div>
    </div>
    </div>
    <div class="row">
    <label for="fName">First Name:<span class="required">*</span></label>
    <input type="text" name="fName" id="fName" value="[[!+fi.fName]]" />
    </div>
    <div class="row">
    <label for="lName">Last Name:<span class="required">*</span></label>
    <input type="text" name="lName" id="lName" value="[[!+fi.lName]]">
    </div>
    <div class="row">
    <label for="address">Street Address:<span class="required">*</span></label>
    <input type="text" name="address" id="address" value="[[!+fi.address]]" />
    </div>
    <div class="row">
    <label for="city">City:<span class="required">*</span></label>
    <input type="text" name="city" id="city" value="[[!+fi.city]]" />
    </div>
    <div class="row">
    <label for="zip">Zip:<span class="required">*</span></label>
    <input type="text" name="zip" id="zip" value="[[!+fi.zip]]" />
    </div>
    <div class="row">
    <label for="phone">Phone Number:<span class="required">*</span></label>
    <input type="text" name="phone" id="phone" value="[[!+fi.phone]]" />
    </div>
    <div class="row">
    <label for="email">E-Mail:<span class="required">*</span></label>
    <input type="text" name="email" id="email" value="[[!+fi.email]]" />
    </div>
    <div class="row">
    <label>Work Order Type:<span class="required">*</span></label>
    <select name="type">
    <option>Select One</option>
    <!--<option value="Select One">Select One</option>-->
    <option value="Irrigation"[[!+fi.type:FormItIsSelected=`irrigation`]]>Irrigation</option>
    <option value="Landscaping"[[!+fi.type:FormItIsSelected=`landscaping`]]>Landscape</option>
    <option value="Pest Control"[[!+fi.type:FormItIsSelected=`pestControl`]]>Pest Control</option>
    <option value="Security"[[!+fi.type:FormItIsSelected=`security`]]>Security</option>
    <option value="Street Lights"[[!+fi.type:FormItIsSelected=`streetLights`]]>Street Lights</option>
    <option value="Other"[[!+fi.type:FormItIsSelected=`other`]]>Other</option>
    </select>
    </div>
    <div class="row">
    <label for="details">Work Order Details:<span class="required">*</span>
    <span>(Please specify the location)</span></label>
    <textarea name="details" id="details" value="" cols="30" rows="10">[[!+fi.details]]</textarea>
    </div>
    <div class="btn-row">
    <button class="submit" type="submit">submit</button>
    <button class="reset" type="reset">reset</button>
    </div>
    </fieldset>
    </form>
      • 8274 ☆ A M B ☆
      • 222 Posts
      First, FormIt only takes preHooks and hooks, I believe. So your snippet for postHooks is probably not being called because I haven't seen a place where FormIt knows what to do with a postHook declaration

      hooks are processed after the form is validated. If you need to change the email address the form gets sent to (using the email hook), you'll need to put your getEmailAdd hook call before the email hook in the hooks list.
      hooks=`getEmailAdd, email...`


      be sure to set your hook value
      $hook->setValue('emailTo', $email)
      as the return of the getEmailAdd snippet, so that the email hook gets the right email address to send to (doing this will overwrite the declared emailTo parameter. If you just want to add additional emails, get the hook value and append it, comma separated, with the new email addresses)

      If that doesn't fix it, posting the content of your getEmailAdd snippet may help.