We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    I’m trying to use eForm to deal with the editing of a record in an external database. So I have a function that is defined in a snippet (ala "populateEmailForm") which is called by eform and which retrieves the data and sets up the form fields. Another function called by eFormOnBeforeMailSent updates the record in the database. Both of these functions are defined in a snippet and seem to work fine.

    What I need to do now is populate a multi-select drop-down list in the form, using the values in a template variable as the total set of choices and the values returned by the database query for a given record as those choices marked as "selected". This would seem to require another function, but I cannot give the "OnBeforeParse" parameter a list of functions to execute.

    Can anyone suggest how this can be done, while maintaining the original functions’ ability to deal with the &fields and &template parameters? Or is there just a better way altogether to go about this? I’m using Evo 1.0.2

    Thanks in advance for any thoughts,
    MattC
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Why can’t your existing function do everything? Breaking functionality into separate functions may be a good programming practice, but it’s not necessary for a program to run. It all ends up reduced to linear code in the machine language no matter what programming style you use.

      Even PHP has bowed to convenience and added a goto operator in 5.3 http://php.net/manual/en/control-structures.goto.php
        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
        • 18913
        • 654 Posts
        Hi,
        Thanks for your reply. I could rewrite the function. The only reason I didn’t immediately go that route is because I figured I missed something smiley
        MattC