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

    I'm using the below code and the form is sending to me fine, however, it doesn't redirect to the thank you page ( 7 ).

    First time I've used formit so not sure what I've done wrong so could someone have a quick check of it for me please.

    This is using Modx 2.2.5 and formit 2.1.2

    [[!FormIt? 
    &hooks=`spam,email,redirect`
    &emailFrom=`[email protected]`
    &emailTo=`[email protected]` 
    &emailSubject =`Add your campsite form` 
    &redirectTo=`7`
    ]]
    <form class="form" id="ajax-contact-form" method="post" action="[[~[[*id]]]]">
    <legend>Your Contact Details</legend>
                            <input type="text" name="name" class="span9" style="margin-right:25px;" placeholder="Name" />
                            <input  class="span9" name="email" placeholder="Email" />
                            <input type="text" name="telephone" class="span9" style="margin-right:25px;" placeholder="Telephone" />
                            <input  class="span9" name="website" placeholder="Website URL" />
                            <textarea type="text" name="address" placeholder="Campsite Address" rows="5" class="span9"></textarea>
    <legend>About Your Campsite</legend>
                            <input type="text" name="sitename" class="span9" style="margin-right:25px;" placeholder="Site Name" />
                            <input  class="span9" name="open" placeholder="Open From / Till" />
                            <textarea type="text" name="pitches" placeholder="Pitches ( Tents, Caravans, Tourers )" rows="5" class="span9" style="margin-right:25px;"></textarea>
                             <textarea type="text" name="onsite" placeholder="On site Amenities" rows="5" class="span9"></textarea>
                            <textarea type="text" name="description" placeholder="Description of Campsite" rows="5" class="span9"></textarea>
                            <hr style="clear: both" />
                            <input type="submit" style="margin-left: 0;" class="btn btn-success span2" value="Submit Campsite" />
                        </form>
      • 38878
      • 255 Posts
      Are you submitting through ajax? If so I cant see how formit would redirect. You should handle that in the success handler of your ajax call.

        • 32025
        • 305 Posts
        Paul,

        Look at this post: http://forums.modx.com/thread/47544/formit-not-redirecting-properly-rc2?page=2#dis-post-460037

        If you have friendly URL's installed it could be the issue. I am having the same issue as we speak.
          Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
          • 22840
          • 1,572 Posts
          Are you submitting through ajax?
          Nope, form method is post



          Quote from: wbbuilder at Mar 25, 2013, 02:44 AM
          Paul,

          Look at this post: http://forums.modx.com/thread/47544/formit-not-redirecting-properly-rc2?page=2#dis-post-460037

          If you have friendly URL's installed it could be the issue. I am having the same issue as we speak.

          That appears to not be adding the / at the end of the url but thats not my issue, mine doesn't even attempt to redirect and if I add the below into my header it has the correct base path with the / but thanks anyway
          [[++site_url]]
            • 36996
            • 211 Posts
            The thank you page is published?
              • 22840
              • 1,572 Posts
              Quote from: nir-z at Mar 25, 2013, 10:43 AM
              The thank you page is published?

              Hi,

              Yes published and accessible by the world and his dog ;o)
                • 38878
                • 255 Posts
                I looked at the site and underlying js and the form submit is apparently being handled by an ajax processor:
                jQuery.noConflict()(function($){
                $(document).ready(function ()
                { // после загрузки DOM
                    $("#ajax-contact-form").submit(function ()
                    {
                        // this указывает на нашу форму
                        var str = $(this).serialize(); // сериализуем данные для POST-запроса
                        $.ajax(
                        {
                            type: "POST",
                            url: "contact.php",
                            data: str,
                            success: function (msg)
                            {
                                $("#note").ajaxComplete(function (event, request, settings)
                                {
                                    if (msg == 'OK') // Если сообщение отправлено, поблагодарим пользователя
                                    {
                                        result = '<div class="notification_ok">Message was sent to website administrator, thank you!</div>';
                                        $("#fields").hide();
                                    }
                                    else
                                    {
                                        result = msg;
                                    }
                                    $(this).html(result);
                                });
                            }
                        });
                        return false;
                    });
                });
                });


                If the 'msg == 'OK' is updating your .notification div, I'm not sure what you expect the redirect hook to do. As I mentioned earlier, the formit redirect post hook is probably just passing the redirected page content in the result but you are ignoring that on success and appending the div with this ajax call.

                Not sure what I'm missing here unless you're working on another version in dev we can't see. If you call it directly w/o ajax does it redirect?

                Quote from: paulp at Mar 25, 2013, 11:53 AM
                Quote from: nir-z at Mar 25, 2013, 10:43 AM
                The thank you page is published?

                Hi,

                Yes published and accessible by the world and his dog ;o)

                Quote from: paulp at Mar 25, 2013, 11:53 AM
                Quote from: nir-z at Mar 25, 2013, 10:43 AM
                The thank you page is published?

                Hi,

                Yes published and accessible by the world and his dog ;o)
                  • 22840
                  • 1,572 Posts
                  Spot on,

                  I didn't even know that was there hence the reason for my answer as I though you were meaning ajax built into Formit

                  Thanks zoluMike
                  • I have similar issue. I don't know where you found AJAX but I'm only using jQuery., which I removed to see if that's the problem. Still not working.I have spet the last six hours trying to test the form, I wondered what was wrong. At least your post provides where the problem is. Any advice will be great. Thankl you.
                    • I added a forward slash to the site directory in .htaccess file (i.e. RewriteBase /site_folder/ )
                      and resolved.

                      site still on localhost