We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5430
    • 247 Posts
    The fact that I can’t find anybody asking about this makes me think it’s probably something I should already know. I can’t find anything about this in the documentation and the pre-population methods discussed in the forum don’t seem to address this, at least none that I’ve seen.

    How can I populate the value of a field on one page via a link’s URL string on a different page? C’mon you geniuses, show me how stupid I am.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Use a snippet to collect the GET array and populate the field with that (make sure to validate and sanitize the GET value before using it!).

      Use the eFormOnBeforeFormMerge event for your snippet. Here’s an example of how to do this, using data from the database.

      http://wiki.modxcms.com/index.php/Populate_eform_with_dynamic_data
        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
        • 5430
        • 247 Posts
        Thx. I had tried a simple GET snippet but not using eFormOnBeforeFormMerge, which is probably why I had no luck. I’ll be calling the snippet from inside the form template, does it matter if it’s a cached or uncached call? I would assume uncached.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          To use a snippet with eForm, call your snippet before the eForm snippet call, and specify the name of the function in your snippet in the eForm snippet parameters. In your function, use the $fields array to add your GET value to the form field.

          Look carefully at the example I linked to; the only difference will be that you’ll be using GET instead of the database functions.
            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