In my previous post I described how I created an end User Configuration Page in MODx. I strongly suggest you look that post over before reading this one.
What I would like to describe now is how I used an email Template Variable (TV) from that configuration page and the eForm snippet to create a contact form for which an end user can control the recipient.
Assumptions
First of all I am assuming you have a text area TV labeled something like Your Email and that you have the GetField snippet installed as well (it gets used from within the eForm snippet call in this example).
I am not assuming that you have extensive knowledge of the eForm snippet as this was my first time to dive into it as well. I found it moderately well documented. You can find supporting documentation in the eform/docs directory within the snippet. There is ample code located there to set up a sample form. I am not going to outline the steps for completely setting up a form in this post, but rather am attempting to outline the points necessary for pulling the Config Page TV, the GetField snippet, and the eForm snippet call together.
Putting it Together
Apparently a typical eForm snippet call would look something like this:
[!eForm? &formid=`feedbackForm` &to=`you@example.com` &from=`((email))` &fromname=`((name))` &replyto=`((email))` &tpl=`eFeedBackForm` &report=`eFeedbackReport` &thankyou=`eFeedbackThanks` &vericode=`1` &subject=`Form: ((name))`!]
All you need to do here is replace the &to email address with the GetField snippet call that is directed to the Config Page with a document ID of 1 and then direct it to return your specific TV housing an email address.
[!eForm? &formid=`feedbackForm` &to=`[[GetField? &docid=`1` &field=`yourEmail`]]` &from=`((email))` &fromname=`((name))` &replyto=`((email))` &tpl=`eFeedBackForm` &report=`eFeedbackReport` &thankyou=`eFeedbackThanks` &vericode=`1` &subject=`Form: ((name))`!]
That’s it. Now the end user can control their contact email address through the Config Page and have their form responses returned accordingly.


