2

I'm trying to build a "send this page to a friend" form in Freeform. My code looks like this:

{% set form = craft.freeform.form("emailToAFriend") %}

{{ form.renderTag({returnUrl: "contact/success"}) }}

    {% if form.hasErrors %}
        <div class="freeform-form-has-errors">
            {{ "There was an error submitting this form"|t }}
        </div>
    {% endif %}

    {% set recipientsName = form.get("recipientsName") %}
    {% set recipientsEmail = form.get("recipientsEmail") %}
    {% set yourName = form.get("yourName") %}
    {% set yourEmail = form.get("yourEmail") %}
    {% set sharedUrl = form.get("sharedUrl") %}
    {% set message = form.get("message") %}

    <label>{{ yourName.label }}</label>
    <input name="{{ yourName.handle }}" value="{{ yourName.value }}" />
    {{ yourName.renderErrors() }}

    <label>Your Email Address</label>
    <input name="yourEmail" />
    {{ form.get("yourEmail").renderErrors() }}

    <label>{{ recipientsName.label }}</label>
    <input name="{{ recipientsName.handle }}" value="{{ recipientsName.value }}" />
    {{ recipientsName.renderErrors() }}

    <label>Their Email Address</label>
    <input name="recipientsEmail" />
    {{ form.get("recipientsEmail").renderErrors() }}

    {{ message.renderLabel() }}
    {{ message.renderInput() }}
    {{ message.renderErrors() }}

    <button type="submit">Submit</button>

{{ form.renderClosingTag }}

How could I get the field in recipientsEmail to pass to that recipient and choose the template?

1 Answer 1

2

The recipientsEmail field should be an Email fieldtype, and in Composer you need to set the notification template in the Field Property Editor column (on right) for that field and it'll send an email to the email that is entered in that field when the form is submitted. :)

View the documentation page here for more information about email notification options: https://solspace.com/craft/freeform/docs/email-notifications/

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.