We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36925
    • 5 Posts
    I've got the code below (I've stripped out the other irrelevant code) which sends emails through correctly if everything is filled in but then just takes you to the same form page. If you don't fill the required fields in then it doesn't send the email but also just returns you to the form page - but doesn't show an error. Resource id 22 is a thank you page and is published.

    Any ideas why? I've been playing with this for a while now but couldn't find the solution in the forums at all.

    Thanks,
    Richard



    
    [[!FormIt?
    &hooks=`email`
    &emailTpl=`sentEmailTpl`
    &emailSubject=`Message from Website`
    &emailTo=`[email protected]`
    &validate=`contact_name:required:minLength=`2`,
          contact_email:email:required,
          contact_message:required`
    &redirectTo=`22`
    ]]
    <form id="contactForm" class="cmxform" method="post" action="[[~[[*id]]]]">
    Please use the form below to send us an email:
    <div>
    <label for="contact_name">Name </label><em>(required, at least 2 characters)</em>
    
    <input id="contact_name" name="contact_name" size="30" class="required" minlength="2" value="[[!+fi.contact_name]]" />
    </div>
    <div>
    <label for="contact_email">E-Mail </label><em>(required)</em>
    
    <input id="contact_email" name="contact_email" size="30"  class="required email" value="[[!+fi.contact_email]]" />
    </div>
    <div>
    
    </div>
    <div>
    <label for="contact_message">Comments </label><em>(required)</em>
    
    <textarea id="contact_message" name="contact_message" cols="30" rows="7" class="required">[[!+fi.contact_message]]
    
    
      • 3749
      • 24,544 Posts
      You need to add redirect to your list of hooks:

      &hooks=`email,redirect`


      The error messages aren't showing because you don't have any placeholders for them in your form. Like this:

      <span class="error">[[!+fi.error.email]]</span>


      Since your form is very simple, you might look at SPForm, which will create a working contact form for you when you install it.
        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
        • 36925
        • 5 Posts
        Thank you for that. I'll bear in mind spform for the future but now this is working I'll leave it in.

        Richard