Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 1.17 KB

usage.md

File metadata and controls

30 lines (20 loc) · 1.17 KB

Usage

When editing a Craft element, the input for a Field Field resembles a Multi Select field.

When editing a Field Field's settings, the allowed fields can be chosen.

Template examples

Accessing a Craft element's field value for a Field Field returns a FieldCollection of the selected fields. The main idea behind Field Field was to make it easy to refer to different fields in different entries within the same entry type; how exactly you'd work with the Field Field value to achieve this depends on whether you've selected one or many fields, but generally involves calling the Craft element's getFieldValue() method with the handle(s) of the selected field(s).

One field selected

{% set field = entry.fieldField.one() %}
{% set fieldValue = entry.getFieldValue(field.handle) %}
{# ... #}

Multiple fields selected

{% for field in entry.fieldField.all() %}
    {% set fieldValue = entry.getFieldValue(field.handle) %}
    {# ... #}
{% endfor %}