form
Generates an HTML <form>
tag, including any required <input>
tags to submit the form to a specific endpoint.
Because there are many different form types available in Shopify themes, the form
tag requires a type. Depending on the
form type, an additional parameter might be required. You can specify the following form types:
Syntax
The name of the desired form type
The form contents
activate_customer_password
Syntax
Generates a form for activating a customer account.
To learn more about using this form, and its contents, refer to the template.
{% form 'activate_customer_password' %}
<!-- form content -->
{% endform %}
Output
cart
Syntax
Generates a form for creating a checkout based on the items currently in the cart. The cart
form requires a cart
object as a parameter.
To learn more about using the cart form in your theme, refer to the cart
template.
{% form 'cart', cart %}
<!-- form content -->
{% endform %}
Output
contact
Syntax
Generates a form for submitting an email to the merchant. To learn more about using this form in your theme, refer to Add a contact form to your theme.
To learn more about the merchant experience of receiving submissions, refer to the Shopify Help Center.
{% form 'contact' %}
<!-- form content -->
{% endform %}
Output
create_customer
Syntax
Generates a form for creating a new customer account.
To learn more about using this form, and its contents, refer to the template.
{% form 'create_customer' %}
<!-- form content -->
{% endform %}
Output
currency
Syntax
The currency
form is deprecated and has been replaced by the localization
form.
Generates a form for customers to select their preferred currency.
Use the filter to include a currency selector inside the form.
{% form 'currency' %}
{{ form | currency_selector }}
{% endform %}
Output
customer
Syntax
Generates a form for creating a new customer without registering a new account. This form is useful for collecting customer information when you don't want customers to log in to your store, such as building a list of emails from a newsletter signup.
To generate a form that registers a customer account, use the form.
To learn more about using this form, and its contents, refer to Email consent.
{% form 'customer' %}
<!-- form content -->
{% endform %}
Output
customer_address
Syntax
Generates a form for creating a new address on a customer account, or editing an existing one. The form requires a specific parameter, depending on whether a new address is being created or an existing one is being edited:
Parameter value | Use-case |
---|---|
| When a new address is being created. |
address | When an existing address is being edited. |
To learn more about using this form, and its contents, refer to the template.
{% form 'customer_address', customer.new_address %}
<!-- form content -->
{% endform %}
{
"customer": {
"new_address": {}
}
}
Output
customer_login
Syntax
Generates a form for logging into a customer account.
To learn more about using this form, and its contents, refer to the template.
{% form 'customer_login' %}
<!-- form content -->
{% endform %}
Output
guest_login
Syntax
Generates a form, for use in the template, that directs customers back to their checkout session as a guest instead of logging in to an account.
To learn more about using this form, and its contents, refer to Offer guest checkout.
{% form 'guest_login' %}
<!-- form content -->
{% endform %}
Output
localization
Syntax
Generates a form for customers to select their preferred country so that they're shown the appropriate language and currency. The localization
form can contain one of two selectors:
- A country selector
- A language selector
The localization
form replaces the deprecated currency
form.
To learn more about using this form, and its contents, refer to Support multiple currencies and languages.
{% form 'localization' %}
<!-- form content -->
{% endform %}
Output
new_comment
Syntax
Generates a form for creating a new comment on an article. The form requires an
article
object as a parameter.
To learn more about using this form, and its contents, refer to the article
template.
{% form 'new_comment', article %}
<!-- form content -->
{% endform %}
Output
product
Syntax
Generates a form for adding a product variant to the cart. The product
form requires a product
object as a parameter.
To learn more about using this form, and its contents, refer to the product
template.
{% form 'product', product %}
<!-- form content -->
{% endform %}
{
"product": {
"id": 6786188247105
}
}
Output
recover_customer_password
Syntax
Generates a form, for use in the template, for a customer to recover a lost or forgotten password.
To learn more about using this form, and its contents, refer to Provide a "Forgot your password" option.
{% form 'recover_customer_password' %}
<!-- form content -->
{% endform %}
Output
reset_customer_password
Syntax
Generates a form for a customer to reset their password.
To learn more about using this form, and its contents, refer to the template.
{% form 'reset_customer_password' %}
<!-- form content -->
{% endform %}
Output
storefront_password
Syntax
Generates a form for entering a password protected storefront.
To learn more about using this form, and its contents, refer to the password
template.
{% form 'storefront_password' %}
<!-- form content -->
{% endform %}
Output
form tag parameters
return_to
Syntax
By default, each form type redirects customers to a specific page after the form submits. For example, the product
form redirects to the cart page.
The parameter allows you to specify a URL to redirect to. This can be done with the following values:
Value | Description |
---|---|
back | Redirect back to the same page that the customer was on before submitting the form. |
A relative path | A specific URL path. For example . |
A routes attribute | For example,
|
{% form 'customer_login', return_to: routes.root_url %}
<!-- form content -->
{% endform %}
{
"routes": {
"root_url": "/"
}
}
Output
HTML attributes
Syntax
You can specify HTML attributes by adding a parameter that matches the attribute name with data-
prepended, and the desired value.
{% form "product", product, id: 'custom-id', class: 'custom-class', data-example: '100' %}
<!-- form content -->
{% endform %}
{
"product": {
"id": 6786188247105
}
}