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

    I am using Wayfinder to pull some data into a form that is using formit to send the data - the data is dynamic, so the contents of the form is CMS controlled so no fixed data is used.... I use wayfinder calls like [[+wf.title]] to place the name of a resource within the form - this works fine... but when I try and output the [[+wf.title]] bit into the formit email TPL it does not fetch the right resource name....

    I can see the data is being sent by formit as if I test with a GET it lists it all in the url field.

    What is not working is the emailTPL getting this data - not sure what code to include in the emailTPL to capture it???

    Is it possible to fetch the data in the emailTPL correctly?

    Cheers,


    dubbs.

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

    [ed. note: dubbs last edited this post 10 years, 9 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      By default if no email tpl is specified it will send a simple list of all the fields in the form and their values.

      I can't quite put my finger on it, but there's something wrong with the whole idea of what you are trying to do.

      How, exactly, is this working? What is the Wayfinder tpl providing?
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 8168
        • 1,118 Posts
        I need a form that is created dynamically from a bunch of resources in a specified folder. It all relates to this other post in the forums Susan - https://forums.modx.com/thread/99189/php-ordering-system-ideas

        So, the elements in the formit form are pulled from the resources - I have that working using TPLs in WayFinder - but the submission of the data to an Email TPL is not working in the formit element. The form works OK as I can see when using a GET action it all seems to be working as it should... But when I try and send the data via the formit Email Tpl - I cant 'render'/get the values of the dropdowns for each element for the various days.

        Additionally - how can I make a formit form store in MODx in the Formit DB feature? I just need a way of getting all the data from the dynamically generated form into a notification email and also stored in the CMS if possible...?

        Really appreciate your insight here.

        Cheers,


        dubbs.
          • 8168
          • 1,118 Posts
          Susan,

          Here is the WayFinder TPL I am using to make up the form for each resource within the designated folder

          <td><select name="[[+wf.title]]_Mon" id="[[+wf.title]]_Mon" value="[[!+wf.title]]]">
          <option>0</option>
          <option value="1" [[!+wf.title_Mon:FormItIsSelected=`1`]]>1</option>
          <option value="2" [[!+wf.title_Mon:FormItIsSelected=`2`]]>2</option>
          <option value="3" [[!+wf.title_Mon:FormItIsSelected=`3`]]>3</option>
          <option value="4" [[!+wf.title_Mon:FormItIsSelected=`4`]]>4</option>
          <option value="5" [[!+wf.title_Mon:FormItIsSelected=`5`]]>5</option>
          <option value="6" [[!+wf.title_Mon:FormItIsSelected=`6`]]>6</option>
          <option value="7" [[!+wf.title_Mon:FormItIsSelected=`7`]]>7</option>
          <option value="8" [[!+wf.title_Mon:FormItIsSelected=`8`]]>8</option>
          <option value="9" [[!+wf.title_Mon:FormItIsSelected=`9`]]>9</option>
          </select></td>
          


          This all works fine in the actual form. But how in the email TPL do I get the value of the select element with the name [[+wf.title]]_Mon ?

          It does not appear to work...
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            The email tpl is problematic, because it has to be given known static field names as its placeholders You won't be able to use a variable for the field (placeholder) name. That plugin is not processed by MODX, it uses an internal str_replace to replace the placeholder with the form field's value.

            If you do not specify a tpl, FormIt's email hook will by default simply list all of the form field names and their values. At least this should work, and can give you the idea of what exactly FormIt sees.

            You'll probably need a hook of some kind to load before the email hook to establish the email tpl, using the variable field names.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 8168
              • 1,118 Posts
              Quote from: sottwell at Jan 02, 2016, 02:04 PM
              The email tpl is problematic, because it has to be given known static field names as its placeholders You won't be able to use a variable for the field (placeholder) name. That plugin is not processed by MODX, it uses an internal str_replace to replace the placeholder with the form field's value.

              If you do not specify a tpl, FormIt's email hook will by default simply list all of the form field names and their values. At least this should work, and can give you the idea of what exactly FormIt sees.

              You'll probably need a hook of some kind to load before the email hook to establish the email tpl, using the variable field names.

              Thanks Susan, yep I can see with no email TPL specified the details come through in an un-formatted list on an email. As you say... the clever bit here therefore is getting a post or pre hook to format the data nicely... Any clues on that?

              P.S. I also cant seem to get formitRetreiver to work - when I move to the submitted form resource I just get a blank page...? Any ideas what might not be working here? I guess maybe the dynamic fields here make this impossible? [ed. note: dubbs last edited this post 10 years, 9 months ago.]
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Yes, those dynamic field names are a problem. A pre-hook might work. Or perhaps have the whole form in a chunk which has a snippet to build the form and the FormIt call. Some way to make FormIt think that it's a normal static form.

                I think that at this point I would re-think my whole design here. Does the option's name really need to be variable? Can some other way produce the desired results?
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 8168
                  • 1,118 Posts
                  Quote from: sottwell at Jan 02, 2016, 02:39 PM
                  Yes, those dynamic field names are a problem. A pre-hook might work. Or perhaps have the whole form in a chunk which has a snippet to build the form and the FormIt call. Some way to make FormIt think that it's a normal static form.

                  I think that at this point I would re-think my whole design here. Does the option's name really need to be variable? Can some other way produce the desired results?

                  Thanks Susan - how would I go about having the form in a chunk which is initiated by a snippet? Any tips?

                  https://forums.modx.com/thread/99189/php-ordering-system-ideas#dis-post-536385 Shows how I need this all to work - so I need a way to build a form from any resources within a designated resource container - using Wayfinder means I can create the form with category headers and the products. I guess, I could abandon this and use getReources instead with just 1 level of products but would prefer to have the tiered products with category headers.
                    • 8168
                    • 1,118 Posts
                    Hi Susan (and others wink) - I can get the form fields into the email TPL by hard coding them, but I need them to be dynamic... Still not sure if this is a possible solution.

                    e.g. I dont know what the contents of the form will be, so I cant hard code the email TPL to present the form data to the recipient... Am really stuck here!
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      You might be able to use a post hook that runs before the email hook, and in that hook use the POST to build the tpl. I'm not sure if you can use @INLINE for the email tpl; if you can you could simply modify the emailTpl property value as passed to the hook. Otherwise you would need to actually build a chunk programmatically, so that it will be the same chunk name as the one specified in the emailTpl, but its content will change in the database as required.
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org