We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19597
    • 44 Posts
    I’ve just spent the last hour staring at the SPForm, eForm, and FormIt documentation and am officially NO CLOSER to having a working form than I was to begin with. I’m absolutely baffled.

    Why does MODx Revo, being as in-depth as it is, not have its own Form Creation?? How is a user with no real php / modx experience supposed to get a form on their page, and get it emailed properly.


    For the love of god, please sad someone help me. I’m completely lost.
      • 5340
      • 1,624 Posts
      This might help:

      For Revo
      http://modxrules.com/articles/send-a-confirmation-email-with-formit
      without the emailUser hook but try it with until you figure it out how it works

      For Evo
      http://modxrules.com/articles/using-eform-with-external-chunks
      Slightly more advanced tutorial that keeps chunks in files

        • 22019
        • 390 Posts
        Cipa’s demo has a couple of things you’re not using, and will confuse you further. At its absolute simplest, as long as there are no other forms on the page, FormIt will send you the bare contents of a form using the following:

        [[!FormIt? &hooks=`email` &emailTo=`***your email address***`]]

        Why not start there and build up....the form will submit to itself and appear to do nothing (check your email).

        Or add a ’Thankyou’ resource and do this, to see it ’working’ more simply.

        [[!FormIt? &hooks=`email,redirect` &emailTo=`***your email address***` &redirectTo=`** ID of your thankyou page`]]

        http://rtfm.modx.com/display/ADDON/FormIt.Examples.Simple+Contact+Page

        Then add validation, customise the email template, add spam handling.... as you get comfortable.

          Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
          • 19597
          • 44 Posts
          Thank you both for your replies and your attempts to assist a frustrated user. Let me begin by saying that other than not understanding FormIt, the rest of my MODx Experience has been amazing.

          I think based on your posts I have a bit more understanding of how FormIt works, please correct me if I’m wrong? :


          - You build your own <form> in straight HTML
          - You place the FormIt call directly above your <form> data (or can it be below? Or anywhere on the same page?)
          - When the Submit button is pressed, FormIt processes the form based on its ID, and includes any hooks/checks you added to it?


          If that’s the case, then my next question(s) are:

          1. <form action="[[~[[*id]]]]" method="post" class="form">

          ^ Where is [[~[[*id]]]] generated, and how does the form know to get that ID?

          2. If I want multiple forms on a page (i.e., I have a contact page that has its own CONTACT US form, but the side of all pages (including contact page) also have a "REQUEST A QUOTE" form. How do I get FormIt to select the right one and process it?



          Thanks again guys, with just those 2 small posts you’ve already been a great help!
            • 5340
            • 1,624 Posts
            1.
            [[*id]] is just a tag that gets replace with the current document id
            [[~[[*id]]]] will take the id and make it a link
            See the tags on the left side of modxrules.com or http://rtfm.modx.com/display/revolution20/Tag+Syntax

            2. Read http://rtfm.modx.com/display/ADDON/FormIt
            If you have multiple forms on a page, set the &submitVar property on your Snippet call to a name of a form element within the form (ie, &submitVar=`form1-submit`). This tells FormIt to only process form requests with that POST variable.
              • 5340
              • 1,624 Posts
              To put FormIt into a page I usually create a special template in modx:

              Example:

              <!DOCTYPE HTML>
              <html lang="en-US">
              <head>
              	<meta charset="UTF-8">
              	<title>[[*pagetitle]]</title>
              </head>
              <body>
              	<h1>[[*longtitle]]</h1>
                  [[*content]]
                      
                  [[!FormIt?  
                      &hooks=`spam,email,redirect`  
                      &emailTo=`YOUR-EMAIL`  
                      &emailSubject=`CONTACT FORM: [[+subject]]`
                      &emailFromName=`[[+name]]`
                      &emailTpl=`ContactTpl`
                      &redirectTo=`6`  
                  ]]
                  
                  <div class="error">[[+fi.error.error_message]]</div>
                  
                  <form action="[[~[[*id]]]]" method="post" class="form">
                      
                      <input type="hidden" name="nospam:blank" value="" />
                  
                      <div class="formRow">
                          <label for="name">Name: </label>
                          <input type="text" name="name:required" id="name" value="[[+fi.name]]" />
                          <span class="error">[[+fi.error.name]]</span>
                      </div>
                      
                      <div class="formRow">
                          <label for="name">Email: </label>
                          <input type="text" name="email:email:required" id="email" value="[[+fi.email]]" />
                          <span class="error">[[+fi.error.email]]</span>
                      </div>
                  
                      <div class="formRow">
                          <label for="subject">Subject: </label>
                          <input type="text" name="subject:required:stripTags" id="subject" value="[[+fi.subject]]" />
                          <span class="error">[[+fi.error.subject]]</span>
                      </div>
                      
                      <div class="formRow">
                          <label for="message">Message: </label><span class="error">[[+fi.error.message]]</span> <br/>
                          <textarea name="message:required:stripTags" id="message" cols="55" rows="7">[[+fi.message]]</textarea>
                      </div>
                      
                      <div class="formRowSubmit">
                          <input type="submit" value="Send" name="Submit"/>
                      </div>
                      
                  </form>
              	
              </body>
              </html>


              This should work by default. Just create the template assign it to a Resource/Document and you are done.
              Don’t forget about the ContactTpl chunk.

              Have fun!
                • 19597
                • 44 Posts
                Thanks again! It’s really coming along quick and that’s just one thing I LOVE about MODx is that the community is very quick and very helpful with new / inexperienced users.

                I think I can make it work now based on the examples and the source that you have provided, I just want to confirm ONE thing before I go on my marry way smiley


                If I have 2 forms on one page, you are saying that I need to set a $SubmitVar to the FormIT call.

                Does this mean that:
                1. If there are 2 Forms on one page, they each require an independent FormIt call?

                2. By element name, I’m assuming you mean name="Submit" portion of the final input of the FORM?

                i.e.:

                        <div class="formRowSubmit">
                            <input type="submit" value="Send" name="Form1-Submit"/>
                        </div>
                
                        <div class="formRowSubmit">
                            <input type="submit" value="Send" name="Form2-Submit"/>
                        </div>
                


                Would become $SubmitVar=’Form1-Submit’ for Form 1

                and $SubmitVar=’Form2-Submit’ for Form 2 (in different FormIt calls, of course).




                If all of what I’ve just said is correct, I think I’m on the right track. If not, I appreciate your insight in enlightening me smiley


                Cheers!
                  • 3749
                  • 24,544 Posts
                  FWIW, SPForm was created just for you. wink

                  In theory, it installs a complete, working contact form when you install SPForm (in Revolution), although I’ve heard rumors that there may be a problem with the install process. I’ll be testing it in a day or two.
                    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
                    • 19597
                    • 44 Posts
                    Quote from: BobRay at Jan 11, 2011, 05:15 PM

                    FWIW, SPForm was created just for you. wink

                    In theory, it installs a complete, working contact form when you install SPForm (in Revolution), although I’ve heard rumors that there may be a problem with the install process. I’ll be testing it in a day or two.

                    I actually used SPForm first, it seemed to install fine (as far as I could tell) with the exception that it doesn’t seem to be able to locate the CSS file that it’s associated with? So the invisible form field for anti-spam was visible, and there were some visual issues that were easily corrected with CSS... However, I was hoping to be able to be more in-depth in the future which is why I was reading into FormIt since it lets me customize many, many different forms with different parameters. I know SP can do this too with the use of different arguments, but it doesn’t seem to have customization options for some things I am hoping to use (or I may have just not figured them out yet since the documentation for SPForm hasn’t been very helpful to me)

                    i.e., I want a form that will have a drop-down box for you to choose who to mail to, but I can’t find that option in SPForm so I was hoping to create my own
                      • 3749
                      • 24,544 Posts
                      SPform has that -- Just set the possible recipients in the &recipientArray parameter.

                      IIRC, it would go like this in Revolution:

                      $recipientArray=`WebMaster: [email protected],Sales: [email protected], Support: [email protected]`


                      I’ll look into the CSS issue.

                      Unfortunatly, the tutorial at my site is for the Evolution version and needs to be updated.
                        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