We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33238
    • 388 Posts
    Hello everyone.

    I have a [[formit call on the top of my pages to manage 3 different forms with different fields.
    it's working well but I need a tpl for every form.

    I was thinking include a <input type="hidden" name="tpl" value="tpl.contactEmail" />

    then call it into the snippet: &emailTpl=`[[+tpl]]`

    so it should replace the placeholder with the name of the tpl on every form, but obviously is not working. sad

    any ideas?

    thank you

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

      --
      ysanmiguel.com
      • 30585
      • 833 Posts
      Have you considered using property sets?

      You could store your tpls in a property set and load your sets "dynamically". I haven't tested this, but it should technically work:

      [[!FormIt@Form[[*id]]]]

      By appending the id of your form pages to the names of your property sets, you'd end up with unique names.

        A MODx Fanatic
        • 37105
        • 194 Posts
        Why not using three different FormIt calls? To address the correct FormIt snippet with the corresponding form just add the following parameter
        &submitVar=`name of id on submit input`
          Codeplaza Webdesign: for professional websites at low cost
          • 3749
          • 24,544 Posts
          +1 for DonQuicky's solution, assuming that you only want to respond to the particular form that was submitted. FormIt will be called three times, but when the submitVar doesn't match, it shouldn't do anything. You will need three Tpl chunks, but you need them anyway to display the three forms (if I'm understanding your question).
            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
            • 33238
            • 388 Posts
            Quote from: BobRay at Feb 22, 2017, 06:47 AM
            +1 for DonQuicky's solution, assuming that you only want to respond to the particular form that was submitted. FormIt will be called three times, but when the submitVar doesn't match, it shouldn't do anything. You will need three Tpl chunks, but you need them anyway to display the three forms (if I'm understanding your question).

            Hello Bob, Yes the idea is use only one formit call to manage and submit any of the 3 forms in the page, for example:

            Contact Form: name, email, comment

            Quick Form: product name, name, email, comment

            Order Form: product name, quantity, colour, name, email, comment

            - As you can see the 3 forms share some fields like name, email and comment, my idea at the beginning was using the output modifiers into the tpl, eg:

            TPL:
            <p>[[+name]]</p> //this is a share field
            <p>[[+email]]</p> //this is a share field
            <p>[[+comment]]</p> //this is a share field
            [[+colour:isnot=``:then=`<p>[[+colour]]</p>`]] //this is a field only for Order form


            So, doing this in my magic world I can use one TPL for all the forms... but didn't work sad
            and I'm not very clear with the treigh's answer about the property sets.

            Do you have any other idea Bob?
            Thank you very much! [ed. note: Ysanmiguel last edited this post 7 years, 2 months ago.]
              --
              ysanmiguel.com
              • 33238
              • 388 Posts
              Any help please?
                --
                ysanmiguel.com
                • 4172
                • 5,888 Posts
                why can't you put three FormIt - calls on the page with different submitVars, like DonQuicky and Bob allready suggested?

                Another way could be, to create a wrapper-snippet, which runs Formit with different properties, depending of some form-field(-value)s.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                • discuss.answer
                  • 33238
                  • 388 Posts
                  Quote from: Bruno17 at Feb 24, 2017, 02:24 PM
                  why can't you put three FormIt - calls on the page with different submitVars, like DonQuicky and Bob allready suggested?

                  Another way could be, to create a wrapper-snippet, which runs Formit with different properties, depending of some form-field(-value)s.

                  Well first than all apologies it was my mistake, I tough Bob said if I use 3 FormIt "FormIt will be called three times" that means 3 mails from the same form but was a misread (english is not my first language) so thanks Bruno for the correction.

                  and special thanks to DonQuicky his idea works perfect, just one small correction:

                  &submitVar read the name of the submit field, not the id.

                  This is the example of one of my forms in case someone need it:

                  FormIT call: &submitVar=`sendFormContact` 
                  
                  tpl: <button type="submit" value="Submit" name="sendFormContact">
                  


                  Thank you very much!
                    --
                    ysanmiguel.com
                    • 3749
                    • 24,544 Posts
                    Sorry my post wasn't more clear. I meant to say that FormIt will be called three times, but two of those times it won't do anything.
                      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
                      • 33238
                      • 388 Posts
                      Quote from: BobRay at Feb 27, 2017, 07:36 PM
                      Sorry my post wasn't more clear. I meant to say that FormIt will be called three times, but two of those times it won't do anything.

                      Right wink

                      Thank you very much Bob!
                        --
                        ysanmiguel.com