register_form_confirmation_field

Registers a form field to be a confirmation_field. A confirmation_field is a field which value will be an email address to which a confirmation mail should be sent after the form is submitted. This will allow you to build forms which send a confirmation mail to the person who filled in the form, and not just to some fixed email address which is given as parameter for the form tag.

You have to give the content for the confirmation email. You can give this by either directly inputting the content into the tag (using the "body" argument), or by specifying a template (theme file). You should put the template in the "mails" folder in the root of your theme. 

Accepts the following arguments (excluding the first argument, which is the name of the form field):

  • body: the content for the confirmation email.

  • template: the template for the confirmation email.

  • subject: the subject for the confirmation email. (Not required, default: 'Confirmation of filling out contact form via %{site}')

Note: Only 1 of the arguments body and template is allowed at the same time. 

Note: This tag does not replace the tag 'register_form_field', so to activate a field in the form, you still have to use the 'register_form_field' tag.

Note: This tag has a gracious error handling, meaning that if a field that is registered as confirmation_field is not given, or does not contain a valid email address, the confirmation mail will not be sent.

Example 1:

{% register_form_confirmation_field "person_email", body: "Thanks for your info!" %}

This will register the field "person_email" as a confirmation_field. When someone fills in the form, and inputs someone@getplate.com in the field person_email, then an email will be sent to someone@getplate.com with the content: "Thanks for your info".

 

Example 2:

{% register_form_confirmation_field "person_email", template: "default_email" %}

This will register the field "person_email" as a confirmation_field. When someone fills in the form, and inputs someone@getplate.com in the field person_email, then an email will be sent to someone@getplate.com with the content found in the theme file located at "/mails/default_email.plate".

The following Objects are accessible inside the mail template:

  • submitted_form_fields similar to the object in that is accessible in the form tag. This allows you to render the submitted fields in the confirmation email.

  • site The same as the site objects inside the Plate templating language

  • form The element that represents the form, so the object used in the for attribute of the form tag.

An example template could look like this (assuming one of the fields is named "Name"):

Dear {{ submitted_form_fields["Name"] }} <br> Thank you very much for your message on {{ site.name }}. We will get back to you within the hour. <br> <br> Kind regards <br> The Plate-Team

Custom Admin Confirmation Mail

You can also use the register_form_confirmation_field tag to send a custom mail to an Admin. In this case, you specify the email address to which a confirmation mail is sent directly with the 'to' argument. This argument is used instead of a confirmation_field in which the email will be provided by the site visitor.

For readability you can use register_form_confirmation. It has the same function as register_form_confirmation_field.

Accepts the following arguments:

  • body: the content for the confirmation email.

  • template: the template for the confirmation email.

  • subject: the subject for the confirmation email. (Required)

  • to: the receiver for the admin confirmation mail. (Required)

Note: In the form tag, to: contact_form.email has to be included as fallback.

Note: Only 1 of the arguments ‘body’ and ‘template’ is allowed at the same time. 

Note: A subject is required. The subject accepts liquid.

Note: If the ‘to’ argument in both the form and register_form_confirmation_field are given, the ‘to’ argument in form will be overwritten.

Note: The ‘body’ does not accept liquid as an argument.

Note: Does not accept a ‘field_name’ value as first argument.

 

Example 1

This will register the argument given for ‘to’ as the email address to which the confirmation mail will be sent. This contains “This is the email subject” as subject and “This is the email body" as the email body.

Example 2

This will render the “name” field, as part of the submitted_form_fields, in the subject line.

The objects that are accessible are the same as for the regular register_form_confirmation_field:

  • submitted_form_fields similar to the object in that is accessible in the form tag. This allows you to render the submitted fields in the confirmation email.

  • site The same as the site objects inside the Plate templating language

  • form The element that represents the form, so the object used in the for attribute of the form tag.