We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8425
    • 159 Posts
    Hello,
    I have a question for you gurus... What would be the best way to pass a value/parameter from a document to another document which contains a eform and then set a field within eform to that value. I hope I make myself understood...
    Thanks for your help
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Probably use the SESSION array, and a custom snippet using an eForm event to load the data into the $fields array.
        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
        • 7231
        • 4,205 Posts
        You do not need a snippet to read the SESSION var (once the SESSION has been set), eForm has built in feature to create placeholders from selected session vars:
        # &sessionVars (optional)
        Comma delimited list of $_SESSION variable names. These will be added to the list of field values before the form is displayed and can for instance be used to populate (hidden) fields. When using this parameter make sure you are not disclosing sensitive information from the session!! (a hidden field is not all that hidden afterall)
        As eForm does not parse the complete form 1st time around you will have to have the same placeholders in the form template so the form can receive the values. So for example: [!eForm &sessionVars=`jobID` ... !]and <input type="hidden" value="[+jobID+]" />
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I’ve read that bit of documentation innumerable times, and that just didn’t register. Very useful to know; I won’t forget about it again!
            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
            • 8425
            • 159 Posts
            Thanks all for your valuable help...
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              You do not need a snippet to read the SESSION var (once the SESSION has been set), eForm has built in feature to create placeholders from selected session vars:
              Just looking though the eform code, and saw that I’m the one that wrote the code to add the session variables to the $fields array! I’d completely forgotten about that rolleyes
                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
                • 7231
                • 4,205 Posts
                Just looking though the eform code, and saw that I’m the one that wrote the code to add the session variables to the $fields array! I’d completely forgotten about that
                LOL
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 3749
                  • 24,544 Posts
                  LOL. That tops my common experience of searching the forums looking for a solution to a problem and finding it in one of my own posts. grin

                    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