Introduction
The different views on your theme may be host to one, or more, forms.
Forms are used to submit data to the platform (such as when a customer's account is created) and to enable the normal workings of the ecommerce parts of your website (like adding a product to your basket).
Some forms on your theme have fields that are required. Unless these fields are populated when the form is submitted the platform will return an error.
The help guides in this section describe each of the forms available, their purpose and what fields are required.
Errors
When a form is submitted, if the platform returns an error the message can be outputted using the errors object. For example,
{% for error in errors %} {{ error }} {% endfor %}
If you are using theme macros then these are already formatted in an easy-to-read format, simply use the variable {{ theme.errors(errors) }}.
Standardised form fields
Some views have standardised form fields. These are: account/create, account/edit, account/login, checkout/login, contact_us, gift_voucher. Ideally all forms should use this standard.
All of these view have two variables, which are always available: errors and form_fields.
errors is the list of form errors, if any.
form_fields is the list of available form fields. Each form field has: name, value, required, type.
name is the name of the form field.
value is the current value (if any) or submitted value (if any).
required is true if the form field is required.
type is usually empty, meaning a normal form field (text box). The other values are: hidden, password and boolean (check box).
Some form fields can also have a values property. This means they should be displayed as a drop down (select list).
The form_fields list also has keys which are always the same, even if the form field name is changed. These can be looped using:
{% for key, field in form_fields %}
... {% endfor %}
The account/create and account/edit views have: company, first_name, last_name, email_address, password, phone, address_line1, address_line2, address_line3, city, postcode, country, source, marketing.
The account/login and checkout/login views have: email_address, password
The contact-us view has: name, email_address, phone, message
The gift-voucher has: amount, type, customer_name, recipient_name, message
The product page has review_errors and review_form_fields, with name, content and rating.