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

    Didn't encounter any issues while I was testing this using localhost and my gmail account, but right now, since I uploaded my project to the live site, I'm encountering this odd blank page after a successful submit. Had a little struggle with the email setup while it was live, but after getting it to work, this problem popped up (QuickEmail email messages go through, and I did check the email account connected to the form and the mail was sent). My form's action link is pointing to the same page (itself), and after submitting, it'd go back to the same page but just show a blank page. I have a &redirectTo in the formit that's not being followed. Here's some details of my installation and the snippet code I use, hoping someone can give an answer to this anomaly tongue

    Using MODX 2.2.6PL with FormIt 2.1.2
    Sharedhosting with Hostmonster using an addon-domain.

    
    [[!FormIt?
       &hooks=`spam,email,redirect`
       &emailTpl=`subscribeEmailMessage`
       &emailFrom=`[email protected]`
       &emailTo=`[email protected]`
       &emailUseFieldForSubject=`1`
       &emailSubject=`Title of my email form`
       &redirectTo=`25`
       &validate=`
          subscribeemail:required,
          subscribename:blank`
    ]]
    
    [[!+fi.error_message:notempty=`<p>[[!+fi.error_message]]</p>`]]
    <form id="subscribe-form" action="[[++site_url]][[~[[*id]]]]" method="post">
    <input type="hidden" name="subscribename" value="" />
    <input type="text" class="email required" name="subscribeemail" value="email addrress" />
    <span class="error">[[!+fi.error.subscribeemail]]</span>
    <input type="submit" class="" value="subscribe"/>
    
    </form>
    


    UPDATE: I took out the spam and redirect hooks, and got rid of the redirectTo and validate parameters. No more blank page in this scenario and the page with the form loads up fine. When I added the redirect hook and the redirectTo parameter, I get the blank page after submission again. It seems there's a problem with the redirector? [ed. note: diatomin last edited this post 13 years, 8 months ago.]
      • 10208 ☆ A M B ☆
      • 1,780 Posts
      Change this:
      <input type="text" class="email required" name="subscribeemail" value="email addrress" />


      to:
      <input type="text" class="email required" name="subscribeemail:required" value="email addrress" />


      You also may want to correct the spelling of address while you're at it :~}
        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 7327
        • 195 Posts
        Thanks! Tried it, but it still shows the blank page sad. I'll take a look if my htaccess rules has anything to do with this..

        UPDATE: Well, tried to clear out the custom stuff I put in there, and even tried out getting rid of the FURL. Didn't change anything. [ed. note: diatomin last edited this post 13 years, 8 months ago.]
          • 7327
          • 195 Posts
          Ok, I've got a workaround to this using custom hooks and doing it MODX EVO way (Modified $url to work even when form is in a page inside folders):

          MY SNIPPET (CUSTOM HOOK) CALLED "customRedirect":

          $redirectId = $hook->getValue('crid');
          $url = $modx->makeUrl($redirectId,'','','http');
          $modx->sendRedirect($url,array('type' => 'REDIRECT_META'));
          
          return true;
          


          MY FORMIT HOOK PARAMETER:

          &hooks=`spam,email,customRedirect`
          


          ADDED HIDDEN INPUT (REDIRECT ID) VALUE TO MY HTML:

          <input type="hidden" name="crid" value="25" />
          


          The only problem I'm seeing here is that the value can be manipulated from the frontend unless there's a validator in place in the FormIt call. Otherwise, this one works for my screwy blank page problem. [ed. note: diatomin last edited this post 13 years, 8 months ago.]
            • 10208 ☆ A M B ☆
            • 1,780 Posts
            oops, you probably also need this:

            name="subscribename"
            to be:
            name="subscribename:blank"

            I tested the form with the new name and it redirected to my id 25 just fine. What's the template and content of your id 25? Is id 25 published?

            edit: I'm slow, you posted while I was distracted. But still, try it with the correct name in the form for the validation and without the custom redirect. I did get a successful redirect with the exact code from above except with the names modified. [ed. note: frogabog last edited this post 13 years, 8 months ago.]
              Frogabog- MODX Websites in Portland Oregon
              "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
              Having server issues? These guys have MODX Hosting perfected - SkyToaster
              • 7327
              • 195 Posts
              Oh ok, so the :blank needs to be specified under the &validate parameter AND inline in the input HTML tags?

              Yep, resource ID 25 is published, it's a simple thank you page. My only issue right now, is if I'm subscribing and the subscription page is located in a container. The makeURL seems to be relative:

              if the form is accessible in the following manner:

              http://www.site.com/category/page.html


              and my thank you page is located:

              http://www.site.com/thank-you.html


              After submitting the form in the above URL, the snippet tries to redirect to:

              http://www.site.com/category/thank-you.html


              Which obviously won't work because the thank you page isn't there :/.

              I'm trying to modify my snippet with this:

              $redirectId = $hook->getValue('crid');
              $siteurl = $modx->config['site_url'];
              $url = $modx->makeUrl($redirectId);
              $final = $siteurl + '/' + $url;
              $modx->sendRedirect($url,array('type' => 'REDIRECT_META'));
              
              return true;
              


              Having no luck though.. I'm don't know what siteurl is showing up. But if I use $siteurl in the sendRedirect function, the page will forward to the homepage after submitting the form.
                • 7327
                • 195 Posts
                Nevermind, using this makeURL form in the snippet worked:

                $url = $modx->makeUrl($redirectId,'','','http');

                I'm editing my snippet above as well in case anyone's interested in copying and pasting that tongue
                  • 7327
                  • 195 Posts
                  Got a question about that :blank in the name attribute of the form. Wouldn't this be self defeating since it can be seen at the frontend?
                    • 10208 ☆ A M B ☆
                    • 1,780 Posts
                    Out of curiosity, does the regular form work without the custom snippet? (with new names in the tag)
                      Frogabog- MODX Websites in Portland Oregon
                      "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                      Having server issues? These guys have MODX Hosting perfected - SkyToaster
                      • 7327
                      • 195 Posts
                      It works if I just use the email hook and remove everything else. the built-in 'redirect' hook gives me a blank page. The blank validator works without specifying it in the name attributes of hidden tags you want to use a spam filter, but specify it in the &validate part of the Formit form.

                      Not sure what you meant by new names in the tag.