Format
{% form '<handle>' attributes %}
<html content>
{% endform %}
|
Description |
Example |
<handle> |
The handle of the form , if setting up a form in the builder this is the name of the form. Otherwise it can be one of the premade forms in the system |
contact |
attributes |
The attributes are inserted as ids or classes on the generate form. |
class:'w-full border rounded p-4' |
<html content> |
The area to include HTML for the form, if not using the built-in format |
See below |
Attributes
Attributes |
Description |
Example |
Redirect |
Defines where the form is redirecting after success |
onSuccess:'/cart' |
Example of HTML content
<div class="form-control">
<label class="{% if form.errors contains 'email' %} input-error{% endif %} flex items-center gap-2">
<input type="email" name="email" class="grow input input-bordered" value="{% if customer %}{{ customer.email }}{% endif %}" placeholder="Email" autocorrect="off" autocapitalize="off" required />
</label>
</div>
<button type="submit" class="btn btn-primary">Send</button>
eCommerce
Customer account forms
{% form 'customer_register' %}
{% form 'activate_customer_password' %}
{% form 'customer_login' %}
{% form 'customer_password_reset' %}
Checkout forms
{% form 'cart_add' %}
{% form 'cart' %}
{% form 'checkout' %}
cart_add
Add product to cart
Example
{% form 'cart_add' %}
<input type="hidden" name="product" value="{{product.id}}">
{% if product.variants.size > 1 %}
<select name="variant" value="{{product.selectedVariant.id}}">
{% for variant in product.variants %}
<option value="{{variant.id}}" {% if variant.id == product.selectedVariant.id %}selected{% endif %}>{{variant.title}}</option>
{% endfor %}
</select>
{% else %}
<input type="hidden" name="variant" value="{{product.selectedVariant.id}}">
{% endif %}
<button name="submit">Add to cart</button>
{% endform %}