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

    I’ve just been using MODx Revo. rc2 (rev6923) and used FormIt v1.1.4 to build my very simple HTML form. The form works and it sends an email. But the redirect page it not correctly handled, the path is wrong.

    This is my formit code inside the contact page resource:


    [[!FormIt?
    &hooks=`spam,email,redirect`
    &emailSubject=`Tigra webform`
    &emailTpl=`email_template`
    &emailTo=`[email protected]`
    &redirectTo=`16`
    &submitVar=`submitContact`
    ]]

    Now it has nothing to do with the HTML encoded &. The form is processed, I receive an email as normal and the resource ID 16 does exist.

    But when the form is send the browser redirects itself to a URL like:

    http://website.comthankyou.html/

    Now the proper page should be:

    http://website.com/thankyou.html

    The slash at the end is wrong and there is no slash after the .com address. I’m using friendly-url rewriting and the normal (main menu) pages are working just fine with rewriting. The resource ID ’16’ has an alias of ’thankyou’. The resource ID ’16’ is hidden from the main menu.

    Anyone have any ideas to fix this redirect problem?
      • 3749
      • 24,544 Posts
      I don’t think this has anything to do with Formit. The Formit redirect hook just uses $modx->makeURL() to generate the URL.

      It could be a problem with makeURL(), but I think it’s very unlikely. Could there be a problem with your rewrite rule(s)? Did you change the container_suffix system setting?
        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
      • If this is being tested in IE, it could be that it is not using the makeURL() API to generate a full URL for the redirect, and IE does not like relative URLs in header redirects.
          • 3749
          • 24,544 Posts
          Here’s the Formit redirect code in (core/components/formit/model/formit/fihooks.class.php):

          $url = $this->modx->makeUrl($this->formit->config['redirectTo']);
                  return $this->modx->sendRedirect($url);


          You could try changing it to this:

          $url = $this->modx->makeUrl($this->formit->config['redirectTo'],'','','full');
                  return $this->modx->sendRedirect($url);
            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
            • 28215
            • 4,149 Posts
            Could one of yall file this as an issue here:

            http://github.com/splittingred/FormIt/issues

            Thanks!
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
              • 8248
              • 3 Posts
              @BobRay,

              Thanx for pointing out the file where to look. I didn’t work as you suggested. BUT, I fixed it with the ’abs’ argument.

              So the new code is:
              $url = $this->modx->makeUrl($this->formit->config['redirectTo'],'','','abs');
              return $this->modx->sendRedirect($url);


              Thanx all for the quick support!!
                • 3749
                • 24,544 Posts
                I’m not sure what to file, because redirect worked out-of-the-box for me when I tried it.

                @dutchwebworks, could you post the issue with your environment variables?
                  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
                  • 28554
                  • 201 Posts
                  I’ve had this issue before, turns out I didn’t have the page published, so it only didn’t redirect correctly in IE because I wasn’t logged in in IE (only in Chrome). Could you confirm this is/isn’t the issue you’re having?
                    • 13697
                    • 19 Posts
                    Hi,

                    I have just installed version 1.6 rc2 of formit and am having the same problem.

                    the / always ends up at the end of the url instead of after the domain extention

                    http://www.domain.co.ukthankyou.html/

                    modx revo 2.1.1 using FURL

                    this is almost 12 months on since someone else had this issue, could it be something to do with the server setup or a system setting or prehaps even a context setting?

                    cheers

                    J
                      • 37667
                      • 18 Posts
                      Hi,

                      I'm struggling with this also and searched the web where I found this thread.

                      When I do not have friendly url turned on, my FormIt redirects just fine. Once I turn on the friendly url, the redirect and emails no longer work. Upon submission, nothing happens and all the form fields return blanks as if the page was just refreshed.

                      I've tried dutchwebworks suggestion in changing the last paramenter of makeURL from 'full' to 'abs', but no luck on getting the redirect or emai to work.

                      I am currently using ModX revolution 2.1.3 and FormIt 2.0.2

                      This is my FormIt code:
                      [[!FormIt? 
                      &customValidators=`validateEmail` 
                      &hooks=`spam,email,FormItAutoResponder`,redirect 
                      &emailTpl=`sentEmailTpl2` 
                      &emailSubject=`Contact form submission` 
                      &emailTo=`[email protected]` 
                      &emailFrom=`Gallery` 
                      &validate=`contact_name:required:minLength=`2`, contact_email:required:svalidEmail, contact_message:required` 
                      &fiarTpl=`cautoResponseTpl` 
                      &fiarSubject=`Thank You for Contacting Us` 
                      &fiarToField=`contact_email` 
                      &fiarFromName=`Gallery Website` 
                      &redirectTo=`7`
                      ]]



                      This is my .htaccess code:

                      RewriteEngine On
                      RewriteBase /
                      
                      RewriteCond %{HTTP_HOST} .
                      RewriteCond %{HTTP_HOST} !^sub\.domain\.com [NC]
                      RewriteRule (.*) http://sub.domain.com/$1 [R=301,L]
                      
                      RewriteCond %{REQUEST_FILENAME} !-f
                      RewriteCond %{REQUEST_FILENAME} !-d
                      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]



                      Any help is appreciated, I really want friendly urls on and need FormIt to work properly.

                      Thanks much!