I have been over the docs and still fall short on this one.
I have a form where customers can dynamically add referrals to notify. I just can't get the email to send.
Here is my freeform code:
{exp:freeform:form
secure_return="yes"
collection="Loyalty Rewards Referrals"
required="loyalty_customer_number|loyalty_customer_name|loyalty_referral_name|loyalty_referral_email"
form_name="referral_form"
form_id="referral_form"
template="loyalty_rewards_referral_notice"
return="/loyalty/thanks"
recipients="yes"
recipient_template="loyalty_rewards_referral_notice_email"
require_ip="yes"
}
I have tried a few different things, but here is the last bit:
<input class="form_field" type="text" name="loyalty_customer_number" id="loyalty_customer_number" />
<input class="form_field" type="text" name="loyalty_customer_name" id="loyalty_customer_name" />
<input class="form_field" type="text" name="loyalty_referral_name" id="loyalty_referral_name" />
<input class="form_field" type="text" name="loyalty_referral_email" id="loyalty_referral_email" />
<input class="form_field" type="text" name="recipient_email_user[]" id="recipient_email_user[]" />
The form itself is hidden and I do some backend validating, during which I add the following prior to submitting:
// Create the needed fields in the form
for (i = 0; i < combinedReferrals.length; ++i) {
$('<input class="form_field" type="text" name="recipient' + i + '" value="' + combinedReferrals[i] + '" />').insertAfter('.form_field:last');
}
Which adds the fields for the dynamic referrals in the format of:
<input class="form_field" type="text" name="recipient1" value="Brian|[email protected]" />
<input class="form_field" type="text" name="recipient2" value="Joe|[email protected]" />
What the heck am I doing wrong here?
* EDIT *
Entire freeform code here:
{exp:freeform:form
secure_return="yes"
collection="Loyalty Rewards Referrals"
required="loyalty_customer_number|loyalty_customer_name"
form_name="referral_form"
form_id="referral_form"
require_ip="yes"
template="loyalty_rewards_referral_notice"
notify="[email protected]"
return="/loyalty/thanks"
recipient_user_input="yes"
recipient_user_limit="1"
recipient_user_template="loyalty_rewards_referral_notice_email"
}
<input class="form_field" type="text" name="loyalty_customer_number" id="loyalty_customer_number" />
<input class="form_field" type="text" name="loyalty_customer_name" id="loyalty_customer_name" />
<input class="form_field" type="text" name="loyalty_referral_name" id="loyalty_referral_name" />
<input class="form_field" type="text" name="loyalty_referral_email" id="loyalty_referral_email" />
{/exp:freeform:form}
Then prior to submit, I loop through an array of entries and populate the following:
// Create the needed fields in the form
for (i = 0; i < combinedReferrals.length; ++i) {
//$('<input class="form_field" type="text" name="recipient' + i + '" value="' + combinedReferrals[i] + '" />').insertAfter('.form_field:last');
$('<input class="form_field" type="checkbox" name="recipient_email_user[]" value="' + combinedReferrals[i] + '" checked />').insertAfter('.form_field:last');
}
Where 'combinedReferrals[i]' is 'Brian|[email protected]'.
* EDIT *
I have the emails sending now using the following code:
{exp:freeform:form
form_name="referral_form"
form_id="referral_form"
notify="[email protected]"
require_ip="yes"
secure_return="yes"
collection="Loyalty Rewards Referrals"
required="loyalty_customer_number|loyalty_customer_name"
return="/loyalty/thanks"
recipients="yes"
recipient_limit="10"
recipient_template="loyalty_rewards_referral_notice_email"
}
<!-- Customer Fields -->
<input class="form_field" type="text" name="loyalty_customer_number" id="loyalty_customer_number" />
<input class="form_field" type="text" name="loyalty_customer_name" id="loyalty_customer_name" />
<!-- Referral Fields -->
<!-- Limit 10 -->
<!-- FreeForm Data -->
<input class="form_field" type="text" name="loyalty_referral_name" id="loyalty_referral_name" />
<input class="form_field" type="text" name="loyalty_referral_email" id="loyalty_referral_email" />
{/exp:freeform:form}
Then the following is writing the values prior to submission:
// Create the needed fields in the form
var splitValue;
for (i = 0; i < combinedReferrals.length; ++i) {
// Split the result
splitValue = combinedReferrals[i].toString().split("|");
// Populate the form
$('<input class="form_field" type="text" name="recipient_name[]" value="' + splitValue[0] + '" />').insertAfter('.form_field:last');
$('<input class="form_field" type="text" name="recipient_email[]" value="' + splitValue[1] + '" />').insertAfter('.form_field:last');
}
Each email is sent to each recipient as it should. However, they want to use the recipient NAME field to personalize the email sent. If I try to use {recipient_name}
I get nothing.
Is there a way to achieve this?