We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19975
    • 429 Posts
    I am receiving the following error log when trying to use the following FormIt code within a chunk, as part of my website.

    The form will not send emails nor redirect.

    [2014-07-03 00:03:41] (ERROR @ /new/revo/index.php) [FormIt] Could not find hook "`email".
    [2014-07-03 00:03:41] (ERROR @ /new/revo/index.php) [FormIt] Could not find hook "redirect`

    MODX Revolution 2.2.14-pl (traditional)
    PHP Version 5.3.28
    formit-2.2.0-pl

    [[!FormIt?
       &hooks=`email,redirect`
       &emailTpl=`wholesaleEmail`
       &emailTo=`[email protected]`
       &emailFromName=`Warrens Bakery`
       &emailSubject=`xxxxx`
       &redirectTo=`57`
       &validate=`name:required,telephone:required,email:email:required,text:required:stripTags,workemail:blank`
    ]]
    [[!+fi.validation_error_message:notempty=`
    <div class="errors">
    	<strong>Some errors were detected in your form:</strong>
    	[[!+fi.error_message]][[!+fi.validation_error_message]]
    </div>`]]
    
    
    
    <form method="post" action="[[~[[*id]]]]#" class="contact-form">
            <fieldset><legend>Email Us</legend>
                <ul>
                    <li>
                        <label for="name">Name:*</label>
                        <input type="text" name="name" class="text cleardefault" placeholder="Name" value="[[!+fi.name]]">
    					[[!+fi.error.name]]
                    </li>
                    <li>
                        <label for="telephone">Tel:*</label>
                        <input type="text" name="telephone" class="text cleardefault" placeholder="Telephone number" value="[[!+fi.telephone]]">
    					[[!+fi.error.telephone]]
                    </li>
                    <li>
                        <label for="email">Email:*</label>
    					<input type="text" name="email" class="text cleardefault" placeholder="Email address" value="[[!+fi.email]]">
    					[[!+fi.error.email]]
                    </li>
                    <li>
                        <label for="text">Message: </label>
                        <textarea name="text" placeholder="Products of interest">[[!+fi.text]]</textarea>
    					[[!+fi.error.text]]
                    </li>
                    	<input type="hidden" name="workemail" value="" />
                    <li><input type="submit" name="submit" class="button1" value="Send Email"></li>
                </ul>
             </fieldset>
      </form>


    wholesaleEmail code:

    <p>This is a response sent by [+name+] using the feedback form on the website. The details of the message follow below:</p>
    <table>
    <tr valign="top"><td>Name:</td><td>[[+name]]</td></tr>
    <tr valign="top"><td>Telephone number:</td><td>[[+telephone_number]]</td></tr>
    <tr valign="top"><td>Email address:</td><td>[[+email]]</td></tr>
    <tr valign="top"><td>Products of interest:</td><td>[[+text]]</td></tr>
    </table>
    <p>You can use this link to reply: <a href="mailto:[[+email]]?subject=RE:Wholesale">[[+email]]</a></p>

      Martin Sanders - Design & Web Development
    • Try uninstalling/reinstalling the FormIt package.
        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
        • 3749
        • 24,544 Posts
        I've seen this before with NewsPublisher, but I don't know what causes it. It looks like the back-ticks for the first and last entry in that property are being sent in the $scriptProperties array, so FormIt is looking for a snippet called `email rather than email and redirect` rather than redirect. I think it's a MODX problem, not a FormIt problem.

        I've wondered if this might be a character set issue where the back-ticks are not being recognized by MODX as back-ticks.

        You could try deleting that property and retyping it to see if that helps.

        As a last resort, IIRC this method worked in NewsPublisher. In the fihooks.class.php file around line 110, change this:

        if (is_string($hooks)) $hooks = explode(',',$hooks);


        to this:

        if (is_string($hooks)) {
           $hooks = trim($hooks, '`');
           $hooks = explode(',',$hooks);
        }

        [ed. note: BobRay last edited this post 9 years, 9 months ago.]
          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
          • 19975
          • 429 Posts
          I updated the formit fihooks.class.php file with the (slightly tweaked) below code which has resolved the initial error. However I now have an error message showing:
          [2014-07-03 18:20:00] (ERROR @ /new/revo/index.php) [FormIt] An error occurred while trying to send the email. Message body empty



          if (is_string($hooks)) {
             $hooks = trim($hooks, '`');
             $hooks = explode(',',$hooks);
          }
            Martin Sanders - Design & Web Development
            • 19975
            • 429 Posts
            I'm still struggling to find a suitable solution. Would this issue be path related?
              Martin Sanders - Design & Web Development
              • 3749
              • 24,544 Posts
              I don't think so. The error message is suggesting that the main content field of the email is empty. The most likely cause of that is a typo in a placeholder or a missing placeholder in the email Tpl chunk.
                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
              • Recently had this happen to a client as well. In our case someone had deleted the response chunk entirely, so with that missing, it caused the same issue. We rebuilt it.
                  • 19328
                  • 433 Posts
                  For anyone landing on this tread having a similar issue. I also did get the "An error occurred while trying to send the email. Message body empty" error. In my case I had set debug=`1` in the FormIt call. When I disabled debug mode, everything was working again (and the body wasn't empty at all...)

                  [ed. note: michelle84 last edited this post 8 years, 7 months ago.]
                    • 577
                    • 132 Posts
                    Quote from: michelle84 at Sep 25, 2015, 10:39 AM
                    For anyone landing on this tread having a similar issue. I also did get the "An error occurred while trying to send the email. Message body empty" error. In my case I had set debug=`1` in the FormIt call. When I disabled debug mode, everything was working again (and the body wasn't empty at all...)


                    Thank you for noting that. I just had the exact same debug issue.
                      "One of these days I will get around to my own website... Its only been about 12 years... maybe tomorrow smiley"
                      • 53161
                      • 130 Posts
                      Bumping this thread to report that I had the same error "No message body" but the REAL problem was that the tpl chunk was missing. I re-created it and it was fixed.