We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27402
    • 1 Posts
    MODx Newbie needs some sage guidance.....

    I need to build a simple form which collects several numeric values. On submission, these need to be added together, some formulas applied to generate some output and a DB query needs to be completed to grab 3 records of comparison data. The results then need to be displayed back to the user.

    Seems like simple stuff but this MODx newbie is now totally confused.

    Questions:

    • Can eForm be used to handle non-emailed outputs? Is this recommended? If not, how to handle?
    • How should the snippet and chunks be organized?
    • Can anyone provide some sample code for how I can insert the calculation items into the eForm process or a sample of an external PHP file to call which will accomplish the same thing?

    Basically, I’m looking for the best strategy for handling a simple form submission via MODx where I just want to perform an operation and bounce the results back to the user. I’m using Evolution w/ eForm 1.4.4.6.

    Huge thanks for helping me along.....

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You can use a parameter to tell it not to send a mail. Then use its event model with an external snippet to get the POST, do your calculations, and add the results to the &$fields array so it can generate the "thankyou" output with your custom data via placeholders as usual.

      This is not exactly what you want, but it is an example of extending eForm using an event. There are other examples in the documentation that comes with eForm.

      http://wiki.modxcms.com/index.php/Populate_eform_with_dynamic_data

      If you want to see a live example of this kind of thing, use my Manager guest login to see how I handle my own contact form. I use the extra information gathered in the GetServer snippet for the emailed report, but it can be used in the "thankyou" report just as easily.
        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
        • 21671
        • 244 Posts
        Hi Susan,

        I really appreciate your response. I was using an event, but must have had a php error someplace. It is actually a snap now that I got it. Now a bit of css, and validation and I should be good.

        Many Thanks,

        Noah