Skip to content

3.3 — Statamic\Fields\Values object renders Term field type as null #5472

Description

@johncarter-

Bug description

It seems that a Term field inside a Statamic\Fields\Values object doesn't properly work with property access.

The term has data as seen in the line retrieving the raw() product_size.

The other field types work:
✅ Text
✅ Toggle
✅ Integer
❌ Term

How to reproduce

$variations = $page->variations;

collect($variations)->each(function (Statamic\Fields\Values $variation) {

            ray($variation); // Statamic\Fields\Values

            ray($variation->toArray()['product_size']->raw()); // ✅ 'jum-8'
            ray($variation->product_size); // 🚨 null

            ray($variation->sku); // 009710446001
            ray($variation->stock); // 1
            ray($variation->enabled); // true
});

Product blueprint (relevant section):

title: Product
sections:
  main:
    display: Main
    fields:
      -
        handle: title
        field:
          type: text
          required: true
          read_only: true
          validate:
            - required
      -
        handle: variations
        field:
          fields:
            -
              handle: product_size
              field:
                max_items: 1
                mode: typeahead
                display: 'Variation Size'
                type: terms
                icon: taxonomy
                width: 50
                listable: hidden
                taxonomies:
                  - product_size
            -
              handle: sku
              field:
                input_type: text
                display: SKU
                type: text
                icon: text
                listable: hidden
                width: 50
            -
              handle: stock
              field:
                display: Stock
                type: integer
                icon: integer
                listable: hidden
                width: 33
            -
              handle: enabled
              field:
                display: Enabled
                type: toggle
                icon: toggle
                width: 25
                listable: hidden
                default: true
          mode: table
          reorderable: true
          display: Variations
          type: grid
          icon: grid
          listable: hidden

Product entry markdown

variations:
  -
    sku: '009710446001'
    stock: 1
    product_size: jum-8
    enabled: true
  -
    sku: '009710446002'
    stock: 1
    product_size: jum-10
    enabled: true
  -
    sku: '009710446003'
    stock: 0
    product_size: jum-12
    enabled: true
  -
    sku: '009710446004'
    stock: 1
    product_size: jum-14
    enabled: true
  -
    sku: '009710446005'
    stock: 1
    product_size: jum-16
    enabled: true
  -
    sku: '009710446006'
    stock: 0
    product_size: jum-18
    enabled: true
  -
    sku: '009710446007'
    stock: 0
    product_size: jum-20
    enabled: false
  -
    sku: '009710446008'
    stock: 0
    product_size: jum-22
    enabled: false
  -
    sku: '009710446009'
    stock: 0
    product_size: jum-6
    enabled: false

Logs

No response

Versions

Statamic 3.3.0-beta.6 Pro
Laravel 8.83.4
PHP 8.1.1
spatie/statamic-responsive-images 2.9.1

Installation

Other (please explain)

Additional details

Can't remember how I installed it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions