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:

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:

1 {% 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"):

1 2 3 4 5 6 7 8 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