We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49478
    • 4 Posts
    Revo 2.3.2

    I have a page that calls a chunk - [[$contactFormTest]]

    The chunk looks like this:

    [[!FormIt?
    &hooks=`spam,email,redirect`
    &emailTo=`[[+emailTo]]`
    &emailTpl=`formEmail`
    &emailSubject=`Contact Form Submission - [[++site_name]]`
    &redirectTo=`6`
    &validate=`name:required`
    ]]
        
    <form class="form" action="[[~[[*id]]]]" method="post">
    <input name="emailTo" type="hidden" value="[email protected]"/>
    <input id="name" name="name" type="text" />
    <input type="submit" value="Get your free assessment »" />
    </form>
    


    That's the only way I can get an email address into the &emailTo field - by passing it from an input value in the actual form, which makes the email address part of the HTML code, which isn't ideal. If I try &emailTo=`x` then the form appears, but obviously doesn't work.

    I tried using [[++emailsender]] but that killed it - same result as typing &emailTo=`[email protected]` so I think it successfully pulled the email address from system settings but died the same way.

    I also tried putting the email address in a property set attached to the chunk, and I could get it to appear in the chunk using [[+emailProperty]], but &emailTo=`[[+emailProperty]]` had the same result, killed Formit.

    One strange thing - it's not a problem on a different Revo 2.3.2 site on the same server. Any ideas?

    This question has been answered by dave25. See the first response.

    • discuss.answer
      • 49478
      • 4 Posts
      Figured out the problem - apparently [[*content]] doesn't like being in a conditional output modifier.

      This was my base template, that everything was running on:

      
      [[*id:is=`1`:then=`
         <!-- homepage stuff -->
      `:else=`
         <!-- interior stuff -->
         <h1>[[*pagetitle]]</h1>
         [[*content]]
      `]]
      
      


      I noticed that when Formit broke, I wasn't getting any interior stuff, not even the [[*pagetitle]] - so then I started to look at the template.

      This works just fine, though:

      
      [[*id:is=`1`:then=`
         [[$homeChunk]]
      `:else=`
        <h1>[[*pagetitle]]</h1>
      `]]
      
      [[*content]]
      
      


      Just can't put [[*content]] in the conditional output modifier for some reason. Or, actually - you can and it usually works, but Formit didn't like that approach.
        • 3749
        • 24,544 Posts
        You could just use a different template for your Home page. It would be a lot faster. BTW, the way you have it, the homeChunk is going to be retrieved on every page at the site, whether it will be used or not.

          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
          • 10208 ☆ A M B ☆
          • 1,780 Posts
          Am getting same results. FormIt works on other sites with output filters in the template containing [[+content]], but not this one. If I add an email instead of using [[++emailFromClientConfig]] the form and entire content breaks. I have a filter based on a radio to turn the sidebar on or off. The content column relies on this to either be full width or smaller if the sidebar is shown.

          I probably can make a new template for forms, but this seems super odd if you ask me. To have a template for one resource where the client can't turn the sidebar off if they wish like all the other pages kinda defeats the purpose if you as me.

          Something in the form also gorks saving. Every resource I put the form into, regardless of if I use a text field, html field, or rte field, chunk, or even turning Content Blocks off for the resource results in a save loop. I re-wrote the formIt call and found the issue with the emailTo adding parameters one by one which finally gave me a usable document, but it's actually the same call as the original one that I've been using for years minus the rampart hook. Mod_security is turned off entirely (did that as soon as the loop showed it's ugly face 2 days ago) but it didn't help and I've trashed 4 resources trying to get one to save.

          It feels like formIt is a dear friend who turned to meth, went stupid and I can do nothing about 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
            • 49478
            • 4 Posts
            yep. i recently did a site where the sidebar has a contact form, and wanted to remove the contact form from the sidebar if the user was on the contact page - because that would be redundant.

            so i tried to wrap the sidebar formit call in a condition -

            [[*id:isnot=`5`:then=`[[$sidebarFormitCall]]`]]

            unfortunately that didn't work - so i ended up having to split it into two templates, one that has [[$sidebarFormitCall]] and one that doesn't.
              • 19872
              • 1,078 Posts
              Quote from: dave25 at Jul 22, 2015, 01:42 PM

              unfortunately that didn't work - so i ended up having to split it into two templates, one that has [[$sidebarFormitCall]] and one that doesn't.

              Instead of having two templates — why not call the form with a snippet. Bob shared a little gem with me, that loads a chunk on a specific resource.

              The following will put your chunk with the contact form on a specific resource.

              <?php
              /*Show contact form snippet */
              $docId = $modx->resource->get('id');
              
              if ($docId == 4) {
                  return $modx->getChunk('nameOfYourChunk');
              } else {
                  return '';
              }
              


              Still trying to wrap my brain around PHP, but if you wanted the contact form on all pages except the contact page, then maybe the following would work?
              Let's say your contact page is resource 8.

              <?php
              /*Show contact form snippet */
              $docId = $modx->resource->get('id');
              
              if ($docId != 8) {
                  return $modx->getChunk('nameOfYourChunk');
              } else {
                  return '';
              }
              


              So if the resource that is loaded is not equal to doc id 8, then load the contact form.

              Just tested and it seems to work. Loads my contact form chunk on every page EXCEPT the one called in the snippet.