Skip to content

Can't access view's array variable with dynamic key #3790

@hmalaud

Description

@hmalaud

Bug Description

When creating an array variable into a given view, trying to access the keys with a dynamic value doesn't seem to work. (Antlers)

How to Reproduce

  1. Create a collection in the CP. E.g.
menu_items: 
  item_1: 
    icon_id: locate
  item_2: 
    icon_id: phone
  item_3: 
    icon_id: basket
  item_4: 
    icon_id: profile
  1. Create an Antlers view with a template variable at the top. E.g.
---
viewbox:
   locate: some_data
   phone: some_data
   basket: some_data
   profile: some_data
---
  1. Loop over the collection (e.g. menu_items) and try to get template's variable keys dynamically
{{ menu_items }}
  {{ icon_id }} // --> locate, phone, basket, profile
  {{ view:viewbox[icon_id] }} // no output
{{ /menu_items }}

Environment

Statamic version: 3.1.18
PHP version: 8.0.2
Laravel version: 8.43.0

Install method (choose one):

  • Starter kit (statamic/statamic)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions