Skip to content

Sources ​

The source field is the field whose items become the options. It can be any field that stores a list or a keyed object:

Source fieldShape of the dataExample items
List, CheckboxesList of stringsSmall, Medium, Large
Grid, ReplicatorList of objects (rows){ name: Alice, role: Design lead }
Array (keyed)Object (key → value)standard: Standard shipping
AssetsList of asset IDsassets::demo/photos/sunset.jpg

The shape decides which Save as modes make sense, and the field warns you if the two don't match.

Set Source type to say where the source field lives: Sibling or ancestor (the default) or Global.

Sibling or ancestor ​

The source field is in the same blueprint as the Field Item Relationship (FIR) field. Enter its handle in Source field.

yaml
- handle: sizes
  field:
    type: list
    display: Sizes
- handle: size
  field:
    type: field_item_relationship
    display: Size
    source_field: sizes
    save_as: value
    input_type: button_group

The options follow the source as it is being edited: add, rename, remove or reorder items in the source field and the picker updates right away, before the entry is saved.

Inside Grid rows and Replicator sets ​

A FIR field can live inside a Grid row or a Replicator set. It looks for the source field in this order:

  1. its own row or set,
  2. then the row or set that contains that one, and so on up,
  3. and finally the top level of the blueprint.

The first match wins. So each Replicator set or Grid row only sees its own items, and it can still reach fields higher up.

This blueprint has a Replicator with a Gallery block. Each block has its own images, a cover picked from those images (a sibling in the same set), and an accent picked from a top-level brand_palette (an ancestor):

yaml
- handle: brand_palette
  field:
    type: list
    display: Brand palette
- handle: blocks
  field:
    type: replicator
    display: Blocks
    sets:
      main:
        display: Blocks
        sets:
          gallery_block:
            display: Gallery block
            fields:
              - handle: images
                field: { type: assets, display: Images, container: assets }
              - handle: cover
                field:
                  type: field_item_relationship
                  display: Cover
                  source_field: images      # sibling in the same set
                  save_as: value
                  input_type: image_grid
              - handle: accent
                field:
                  type: field_item_relationship
                  display: Accent
                  source_field: brand_palette   # ancestor at the top level
                  save_as: value
                  input_type: button_group

A Replicator gallery block with three images and a Cover picker that only offers those three imagesA Replicator gallery block with three images and a Cover picker that only offers those three images

The Cover picker only offers the images of its own Gallery block.

Grid rows work the same way, also when the Grid itself is inside a Replicator set. A default_variant field in a Grid row lists only that row's variants:

yaml
- handle: products
  field:
    type: grid
    fields:
      - handle: product
        field: { type: text }
      - handle: variants
        field: { type: list }
      - handle: default_variant
        field:
          type: field_item_relationship
          source_field: variants    # the List in the same Grid row
          save_as: value

In templates, nested fields are used inside their loop like any other field:

antlers
{{ blocks }}
  {{ if type == "gallery_block" }}
    <img src="{{ cover:url }}" alt="">
    <p>Accent: {{ accent }} · Cover file: {{ fir:cover:basename }}</p>
  {{ /if }}
{{ /blocks }}

The search only goes up

A field can't see into other rows, other sets, or rows below it. If the handle isn't in its own row or any row above, you get The source field "…" could not be found.

Global ​

Set Source type to Global, pick the Source global set, and enter the handle of a field in that set as Source field.

yaml
- handle: office
  field:
    type: field_item_relationship
    display: Office
    source_type: global
    source_global_set: demo_settings
    source_field: offices
    save_as: object_key
    object_key: city
    option_label_source: '`${o.city}, ${o.country}`'
    option_image_source: photo
    input_type: image_grid
    columns: 3
    aspect_ratio: 3/2

An image grid of offices (Stockholm, Oslo, Copenhagen) built from a Grid in a Global setAn image grid of offices (Stockholm, Oslo, Copenhagen) built from a Grid in a Global set

Offices from a Grid in the Demo Settings global, labelled with a string literal.

Multisite ​

Global sets can hold different data per site. The field reads the global data of the site of the entry being edited: when you switch an entry to Swedish in the control panel, the options come from the Swedish global. If the global set has no localization for that site, the default site is used.

On the front end, the fir tag does the same: it resolves against the site of the entry, and fir:global_set:field uses the current site.

Make the field localizable

If the global data differs per site, the saved value most likely does too. Mark the FIR field as localizable: true so each site keeps its own selection.

Empty sources ​

An empty source is not an error. The field shows Source field "…" has no items. and becomes selectable once the source has data.

Released under the MIT License. Made with fruit by kiwikiwi