Last active
January 20, 2016 19:10
-
-
Save howellcc/3c16b480e69b094acb6b to your computer and use it in GitHub Desktop.
[MuraCMS] Confirmation email for a form builder form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Place this code in your theme-leve eventHandler.cfc. | |
public any function onAfterFormSubmitSave($) output="true"{ | |
if(len($.event('CONFIRMATIONEMAIL')) and isValid('email',$.event('CONFIRMATIONEMAIL'))) { | |
local.formFields = deserializeJSON($.event('formbean').getbody()).form.fields; | |
local.mailSvc = new mail(); | |
local.mailSvc.setTo($.event('CONFIRMATIONEMAIL')) | |
.setFrom("[email protected]") | |
.setSubject("My important subject") | |
.setType("html"); | |
local.mailBody = "<html><body> | |
<p>Put your confirmation text here. </p> | |
<h3>Fieldset Label</h3> | |
<table> | |
<tr><td>#getFieldLabel(formFields,'field1Name')#</td><td>#$.event('field1Name')#</td></tr> | |
<tr><td>#getFieldLabel(formFields,'field2Name')#</td><td>#$.event('field2Name')#</td></tr> | |
</table> | |
</body></html>"; | |
local.mailSvc.send(body=local.mailBody); | |
} | |
} | |
private string function getFieldLabel(required any formFields, required string fieldName){ | |
for(local.thisFieldID in structKeyList(formfields)){ | |
if(lcase(formFields[local.thisFieldID].name) eq lcase(fieldName)) | |
return formFields[local.thisFieldID].label; | |
} | |
return ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment