Modx: How to create a contact form with a dropdown of offices to cc the email to?

StackOverflow https://stackoverflow.com/questions/1441403

  •  10-07-2019
  •  | 
  •  

Question

In the contact us template I want to have a dropdown with the list of offices (All offices articles are places under the same parent node, so getting the list should be fairly easy). I need a way to add the office email address (Template variable from the Office article) to the email generated by Modx's eForm. I don't want the email address to be visible in the contact us form, but a snippet fetching the article Template variable email address.

I also want a link from each offices article to the contact us form with the office preselected in the dropdown.

How should I implement this?

Was it helpful?

Solution

Ok, to solve this I removed the to field in the snippet call to eform, and modified the snippet itself to exetute a function to get the to field for the email. This function takes the post variable "office" (the id of the office article) and is using the modx api to get the template variable holding the email address for this article.

Then I am returning this email address from the function and placing this into the email to field. By adding a regular link from each location article with

...?office=[~id~] 

pointing to the contact us article. Using

$_GET["office"] 

to predefine the dropdown

OTHER TIPS

You should really look into eForm. has such an action where you can put &cc=xxx@example.com

snippet call:

[!eForm? &formid=`feedbackForm` &to=`mail@client.com,mail2@client.com` &mailselector=`department` &tpl=`eFeedbackForm` &report=`eFeedbackReport` &gotoid=`46` &vericode=`1`!]

the form would be set up under a chunk eFeedbackForm and your dropdown selection should look like:

<p><label accesskey="s">Send To</label><br />
<select name="department" style="width: 232px">
            <option value="1">Mail1</option>
            <option value="2">Mail2</option>
    </select></p>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top