Fieldset

Fieldset

{{ fieldset }}

A group of fields which together define a custom object. May either define a single object or a list of objects.

Name Type Description
is_valid Boolean True if there is at least one custom object
value String The same as what you would see when inspecting this object. For fieldset fields you do not typically care about this - use objects or fields instead
allow_multiple Boolean True if the fieldset allows multiple objects to be entered. Changes the way some of the other fieldset properties work
objects list A list of custom data objects defined by this fieldset. Only if allow_multiple is true
fields list A single custom data object defined by this fieldset. Only if allow_multiple is false
field_id String The identifier for this field
label String The label for this field
output String Same as value. May include additional markup in the editor preview to make it easier to edit content

Field containing either a single custom object or multiple custom objects - depending on whether allow_multiple is true.

You may also treat this object as a list containing all of the child objects (if allow_multiple is true) or fields (if allow_multiple is false) which may be iterated using a {% for %} loop. For more details see the examples below:

If allow_multiple is false, individual fields may be accessed using the {{ object.keyName }}, {{ object['keyName'] }}, {{ object.fields.keyName }}, or object.fields['keyName'] syntax.

You may also treat this object as a list containing all of the fields which may be iterated using a {% for %} loop. For more details, see the examples below:

Examples

Working with specific fieldset properties

Copy
{% if entity.fieldset.is_valid %} {% unless entity.fieldset.allow_multiple %} {% if entity.fieldset.field1.is_valid %}

Field 1 Value: {{entity.fieldset.field1}}

{% endif %} {% if entity.fieldset['field2'] %}

Field 2 Value: {{entity.fieldset['field2']}}

{% endif %} {% if entity.fieldset.fields.field3.is_valid %}

Field 3 Value: {{entity.fieldset.fields.field3}}

{% endif %} {% if entity.fieldset.fields['field4'] %}

Field 4 Value: {{entity.fieldset.fields['field4']}}

{% endif %} {% endunless %} {% endif %}

List all objects in a fieldset field

Copy
{% if entity.fieldset.is_valid and entity.fieldset.allow_multiple %}
    {% for object in entity.fieldset %} --equivalent to {% for object in entity.fieldset.objects %}
  • {{ object.custom_title }}{% if object.custom_description.is_valid %}
    {{ object.custom_description }}{% endif %}
  • {% endfor %}
{% endif %}

List all values in a fieldset field

Copy
{% if entity.fieldset.is_valid %} {% unless entity.fieldset.allow_multiple %}
    {% for field in entity.fieldset %} --equivalent to {% for field in entity.fieldset.fields %}
  • {{field.field_id}} = {{field.output}}
  • {% endfor %}
{% endunless %} {% endif %}