I have a situation where I need a form to submit and be sent to my company's email address AND to an email address outputted from an email field from the entry that the form sits on. Is it possible to have a hidden input in the template that contains the email addresses I want the notification to go to?
1 Answer
I've figured this out (the solution is not in the docs). Follow these steps:
1) In the amforms plugin's settings, create a custom text field called 'notificationRecipients'.
2) Add that field to your form's list of fields in the form's settings.
3) Under the notifications tab of your form, add this to your "Email Recipients" field:
[email protected],{notificationRecipients}
4) Now in your template, add a hidden input in the <form>
like so:
<input type="hidden" name="fields[notificationRecipients]" value="{{ entry.yourCustomFieldEmailAddress }}">
Keep in mind that multiple emails should be separated by commas like [email protected],[email protected],[email protected]
That's it!
If you don't want the list of email recipients to appear in your notification email, then you need to edit line 24 of craft/plugins/amforms/templates/_display/templates/email.twig to look like this:
{% for field in fields if field.getField().handle != 'notificationRecipients' -%}
Additional examples and info can be found on these closed issues of the developer's git page: