Form tags
Below you find all the tags relating forms:
form
Renders an HTML form that saves the message to the database so the user can find it under 'Messages' in the dashboard.form_input_name
Returns a string that can be used as name for HTML input tags inside the form Liquid tagregister_form_field
Registers a form field by name in Plate.register_form_confirmation_field
Registers a form field where an email address is submitted which a confirmation mail should be sent to after submitting the formsubmitted_form_fields
Allows you to render the submitted fields in the confirmation email.
form_input_name
Returns a string that can be used as name for HTML input tags inside the form Liquid tag. This filter must be used to ensure that an input field is processed correctly by Plate. The input for this filter is the name that represents the field, for example “Name” or “Email”. Read more about html_input to change te input type
register_form_field
Registers a form field by name, in Plate. This ensures that when a form is submitted Plate expects this form, and possibly validates the field. The tag can only be used within a form block. It accepts the name of the field as an input (for example “Name” or “Email”), but also whether this field should be validated (with the required
argument).
Accepts the following arguments (excluding the first argument, which is the name):
required
: whether the registered field should be validated on presence. (Default:false
)array
: whether the input sent for the registered field is an array. E.g. with multiple file fields (Default:false
)
Note that this tag does not directly output anything in the HTML. In the background this tag adds some information to a hash that is generated by the form tag.
To generate the HTML, use the form_input_name and html_input filters.
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 to overwrite the template which is send to the fixed email address which is given as parameter for the form tag.
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.
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.
User Custom confirmation email
Example 1:
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:
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".
Admin custom confirmation email
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.
The following Objects are accessible inside the mail templates:
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 thesite
objects inside the Plate templating languageform
The element that represents the form, so the object used in thefor
attribute of the form tag.
An example template could look like this (assuming one of the fields is named "Name"):