The form field object and its typed field variants.
{{ form_field }} is the shared shape for a form control. It is not a separate runtime type: each field is one of the typed field objects on this page (text_field, select_field, and the rest). Use object_type or type to tell which implementing type you have. Typed objects add the properties for that field type.
{{ form_field }}
{{ form_field }} is the shared shape for a form control. It is not a separate runtime type: each field is one of the typed field objects (text_field, select_field, and the rest). Use object_type or type to tell which implementing type you have.
The default output that the form_field would produce if it were output directly to the template. The default output may change at any time. Template developers should avoid using this and should handle the output of different form fields themselves. May include additional markup in the editor preview to make it easier to edit content
Typed field objects add further properties that are not listed here. See each type on this page.
ExampleLoad one form and list each form_field label{% form %} loads a single form by name or GUID; fields is the list of form_field controls on that form.
Liquid
{%- form var contact = "Contact Us" -%}
{%- if contact.is_valid -%}
<h2>{{ contact.title }}</h2>
<ul>
{%- for field in contact.fields -%}
<li>{{ field.label }} ({{ field.object_type }})</li>
{%- endfor -%}
</ul>
{%- endif -%}
{{ hidden_field }}
Should be used to output a hidden field inside a form, which by definition is not displayed to or directly editable by users.
CSS class name(s) to be applied to the field. Although the field is not displayed, the classname may still be used when setting the field value (eg: for the editor to specify the type of data to save in the field)
If the user is signed into a profile when they submit this form and map_to_attribute is set, the profile attribute specified in map_to_attribute will be set to the value of this field. This should also be used to override the default value if the user is signed into a profile and the specified attribute has already been set
Default HTML markup for this field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more
Hidden form fields are generally only useful for template developers, since the user is not able to directly edit their value. When including a hidden field in a form, developers should ensure that there is some way for the value to be set - typically either using liquid markup to specify the value explicitly in the template or using javascript after the form is displayed to calculate and set a dynamic value
ExampleOutput hidden_field using field_id as the name attributehidden_field has no label; field_id is the value to use for the input's name attribute, and its value must be supplied by the template.
A dictionary containing all of the checkboxes and their values to be included in the checkboxlist, where the keys are the value to be stored and the values are the text to be displayed
The string that should be used to distinguish the value for each option from the text to be displayed, where the value is to the left of value_delimiter and the text is to the right. Any options that do not contain the value_delimiter will use the full option as both the text and the value
The raw and un-parsed default value for this checkboxlist field. Includes all of the values for the options that should be checked by default, separated by the delimiter
If the user is signed into a profile when they submit this form and map_to_attribute is set, the profile attribute specified in map_to_attribute will be set to the value of this field. This should also be used to override the default value if the user is signed into a profile and the specified attribute has already been set
Default HTML markup for this checkboxlist, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
ExampleLoop a field's items and read its option delimitersselect_field, radio_field, and checkboxlist_field all expose items, options, delimiter, value_delimiter, and count for their option lists; select_field also adds allow_multiple.
Liquid
{%- if form_field.object_type == "select_field" or form_field.object_type == "radio_field" or form_field.object_type == "checkboxlist_field" -%}
<p>{{ form_field.label }} ({{ form_field.count }} option(s), delimited by "{{ form_field.delimiter }}")</p>
<ul>
{%- for key in form_field.items -%}
<li data-value="{{ key }}">{{ form_field.items[key] }}</li>
{%- endfor -%}
</ul>
{%- if form_field.object_type == "select_field" and form_field.allow_multiple -%}
<p class="hint">This select list allows more than one selection.</p>
{%- endif -%}
{%- endif -%}
{{ textarea_field }}
Should be used to display a textarea field inside a form.
If the user is signed into a profile when they submit this form and map_to_attribute is set, the profile attribute specified in map_to_attribute will be set to the value of this field. This should also be used to override the default value if the user is signed into a profile and the specified attribute has already been set
Default HTML markup for this textarea field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
ExampleRead placeholder, default value, and validators for text-like fieldstext_field and textarea_field share placeholder, default_value, and validators; only text_field adds is_numeric.
Liquid
{%- if form_field.object_type == "text_field" or form_field.object_type == "textarea_field" -%}
<label>{{ form_field.label }}</label>
<input type="{{ form_field.type }}" placeholder="{{ form_field.placeholder }}" value="{{ form_field.default_value }}">
{%- if form_field.object_type == "text_field" and form_field.is_numeric -%}
<p class="hint">Numbers only.</p>
{%- endif -%}
{%- if form_field.validators.is_valid -%}
<p class="hint">{{ form_field.validators.validators | size }} rule(s) apply to this field.</p>
{%- endif -%}
{%- endif -%}
{{ checkbox_field }}
Should be used to display a checkbox field inside a form.
If the user is signed into a profile when they submit this form and map_to_attribute is set, the profile attribute specified in map_to_attribute will be set to "true" or "false". This should also be used to override the default value if the user is signed into a profile and the specified attribute has already been set
Default HTML markup for this field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
ExampleRead checkbox_field's boolean default and required statecheckbox_field's default_value is a boolean rather than text; required marks whether the box must be checked before the form can submit.
Liquid
{%- if form_field.object_type == "checkbox_field" -%}
<label>
<input type="checkbox" name="{{ form_field.field_id }}"{% if form_field.default_value %} checked{% endif %}{% if form_field.required %} required{% endif %}>
{{ form_field.label }}
</label>
{%- if form_field.required and form_field.required_message -%}
<p class="hint">{{ form_field.required_message }}</p>
{%- endif -%}
{%- endif -%}
{{ file_field }}
Should be used to display a file upload field inside a form.
A string containing the types of files that may be uploaded using this field. Intended to be used directly in the "accept" property of an HTML file input element
Default HTML markup for this file field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
There may be additional restrictions on file uploads that are not specified in the validators, such as max upload filesize. Furthermore, after being uploaded, all files are automatically scanned for malware, although that does not prevent users from uploading malicious files; it only reports the expected security status of the file to administrators
ExampleRestrict uploads with file_field's accept and allow_multiplefile_field's accept restricts which file types the browser offers, and allow_multiple controls whether more than one file may be uploaded at once.
Default HTML markup for this group and all of the fields in this group, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
Groups may be deeply nested, which templates should be able to handle. Template developers may optionally handle collapsing and expanding groups, although if possible it is recommended to allow it for optimal feature parity with the editor options when editing form fields
ExampleLoop a group_field's nested fields and show its collapse stategroup_field's fields property holds the nested form_field list for the group, which may include other groups; collapsible and collapsed control whether it starts partially hidden.
Liquid
{%- if form_field.object_type == "group_field" -%}
<fieldset class="{{ form_field.classname }}"{% if form_field.collapsible and form_field.collapsed %} data-collapsed="true"{% endif %}>
<legend>{{ form_field.label }}</legend>
{%- for nested_field in form_field.fields -%}
<p>{{ nested_field.label }} ({{ nested_field.object_type }})</p>
{%- endfor -%}
</fieldset>
{%- endif -%}
{{ submit_field }}
Should be used to display a submit button inside a form.
If true, the template should use the button_html property when displaying the submit button. If false, the template should use the button_text property, which should be propertly escaped since it is not supposed to contain HTML markup
Default HTML markup for the submit button, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
Almost every form should have one and only one submit button.
ExampleShow a button's text or HTML, plus button_field's extra controlsbutton_field and submit_field share button_text, button_html, and text_is_html; only button_field adds button_type and on_click.
Liquid
{%- if form_field.object_type == "button_field" or form_field.object_type == "submit_field" -%}
<button type="{{ form_field.type }}">
{%- if form_field.text_is_html -%}
{{ form_field.button_html }}
{%- else -%}
{{ form_field.button_text }}
{%- endif -%}
</button>
{%- if form_field.object_type == "button_field" -%}
<p class="hint">button_type: {{ form_field.button_type }}{%- if form_field.on_click -%}, has a custom on_click handler{%- endif -%}</p>
{%- endif -%}
{%- endif -%}
{{ button_field }}
Should be used to display a custom button inside a form.
If true, the template should use the button_html property when displaying the button. If false, the template should use the button_text property, which should be propertly escaped since it is not supposed to contain HTML markup
The custom javascript to execute when this button is clicked. Note that there is no guarantee that the javascript is valid or that any other functions or variables that it may reference have been defined. This functionality should only be used by developers and power users who know what they are doing
Default HTML markup for the button field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
The button field should only be used by power users who know what they are doing, and should always be tested to ensure that it works as anticipated. Most of the time the submit field should be used instead.
ExampleShow a button's text or HTML, plus button_field's extra controlsbutton_field and submit_field share button_text, button_html, and text_is_html; only button_field adds button_type and on_click.
Liquid
{%- if form_field.object_type == "button_field" or form_field.object_type == "submit_field" -%}
<button type="{{ form_field.type }}">
{%- if form_field.text_is_html -%}
{{ form_field.button_html }}
{%- else -%}
{{ form_field.button_text }}
{%- endif -%}
</button>
{%- if form_field.object_type == "button_field" -%}
<p class="hint">button_type: {{ form_field.button_type }}{%- if form_field.on_click -%}, has a custom on_click handler{%- endif -%}</p>
{%- endif -%}
{%- endif -%}
{{ select_field }}
Should be used to display a select list inside a form.
Whether or not to allow users to select more than one option from this select list
items
object
A dictionary containing all of the options and their values to be included in the select list, where the keys are the value to be stored and the values are the text to be displayed
The string that should be used to distinguish the value for each option from the text to be displayed, where the value is to the left of value_delimiter and the text is to the right. Any options that do not contain the value_delimiter will use the full option as both the text and the value
The raw and un-parsed default value for this select list. Includes the value of all options that should be selected by default, separated by the delimiter
If the user is signed into a profile when they submit this form and map_to_attribute is set, the profile attribute specified in map_to_attribute will be set to the value of this field. This should also be used to override the default value if the user is signed into a profile and the specified attribute has already been set
Default HTML markup for this field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
ExampleLoop a field's items and read its option delimitersselect_field, radio_field, and checkboxlist_field all expose items, options, delimiter, value_delimiter, and count for their option lists; select_field also adds allow_multiple.
Liquid
{%- if form_field.object_type == "select_field" or form_field.object_type == "radio_field" or form_field.object_type == "checkboxlist_field" -%}
<p>{{ form_field.label }} ({{ form_field.count }} option(s), delimited by "{{ form_field.delimiter }}")</p>
<ul>
{%- for key in form_field.items -%}
<li data-value="{{ key }}">{{ form_field.items[key] }}</li>
{%- endfor -%}
</ul>
{%- if form_field.object_type == "select_field" and form_field.allow_multiple -%}
<p class="hint">This select list allows more than one selection.</p>
{%- endif -%}
{%- endif -%}
{{ radio_field }}
Should be used to display a radio field inside a form.
A dictionary containing all of the options and their values to be included in the template, where the keys are the value to be stored and the values are the text to be displayed
The string that should be used to distinguish the value for each option from the text to be displayed, where the value is to the left of value_delimiter and the text is to the right. Any options that do not contain the value_delimiter will use the full option as both the text and the value
If the user is signed into a profile when they submit this form and map_to_attribute is set, the profile attribute specified in map_to_attribute will be set to the value of this field. This should also be used to override the default value if the user is signed into a profile and the specified attribute has already been set
Default HTML markup for this radio field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
ExampleLoop a field's items and read its option delimitersselect_field, radio_field, and checkboxlist_field all expose items, options, delimiter, value_delimiter, and count for their option lists; select_field also adds allow_multiple.
Liquid
{%- if form_field.object_type == "select_field" or form_field.object_type == "radio_field" or form_field.object_type == "checkboxlist_field" -%}
<p>{{ form_field.label }} ({{ form_field.count }} option(s), delimited by "{{ form_field.delimiter }}")</p>
<ul>
{%- for key in form_field.items -%}
<li data-value="{{ key }}">{{ form_field.items[key] }}</li>
{%- endfor -%}
</ul>
{%- if form_field.object_type == "select_field" and form_field.allow_multiple -%}
<p class="hint">This select list allows more than one selection.</p>
{%- endif -%}
{%- endif -%}
{{ label_field }}
Should be used to display a text label inside a form.
Help or hint text to display together with the label. Not typically used for label fields, although the developer may specify an alternate use for this or may customize the output using this
Default HTML markup for this label, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
How the label is displayed in the form is entirely up to the template developer as there is currently no way for editors to specify the styling to use when displaying labels
ExamplePrint label_field's text and classnamelabel_field only carries display text and an optional condition; it has no value of its own to submit.
Default HTML markup for the captcha field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
Captcha fields are recommended in order to prevent bots from spamming forms, although each form may only have a single catpcha field. Additionally, it is not recommended for the captcha field to be conditional, as that would defeat its purpose.
ExampleRead captcha_field's theme, size, and site keycaptcha_field's theme, captcha_size, and google_recaptcha_site_key configure a Google reCAPTCHA widget.
Will be true if the field should only be used to enter numbers, which may only include integers or may include decimals as well. This is a convenience property which uses the validators to check if the field validates for numeric or decimal values
If the user is signed into a profile when they submit this form and map_to_attribute is set, the profile attribute specified in map_to_attribute will be set to the value of this field. This should also be used to override the default value if the user is signed into a profile and the specified attribute has already been set
Default HTML markup for this field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
The text field may also be used to display number inputs, although there are not number-specific properties (eg: increment) so it is currently up to the template developer's discretion how they want to display number inputs
ExampleRead placeholder, default value, and validators for text-like fieldstext_field and textarea_field share placeholder, default_value, and validators; only text_field adds is_numeric.
Liquid
{%- if form_field.object_type == "text_field" or form_field.object_type == "textarea_field" -%}
<label>{{ form_field.label }}</label>
<input type="{{ form_field.type }}" placeholder="{{ form_field.placeholder }}" value="{{ form_field.default_value }}">
{%- if form_field.object_type == "text_field" and form_field.is_numeric -%}
<p class="hint">Numbers only.</p>
{%- endif -%}
{%- if form_field.validators.is_valid -%}
<p class="hint">{{ form_field.validators.validators | size }} rule(s) apply to this field.</p>
{%- endif -%}
{%- endif -%}
{{ date_field }}
Should be used to display a date field inside a form.
If the user is signed into a profile when they submit this form and map_to_attribute is set, the profile attribute specified in map_to_attribute will be set to the value of this field. This should also be used to override the default value if the user is signed into a profile and the specified attribute has already been set
Default HTML markup for this date field, which makes a number of assumptions about other elements on the page that may or may not be included. Developers should avoid using the default output in order to guarantee that forms work as expected, including styling, validation, conditionals, and more. May include additional markup in the editor preview to make it easier to edit content
ExampleShow date_field's default value only when one is setdate_field's default_value is optional and returns null when unset, so guard before printing it as the input's value.