lewisjenkins / craft-dynamic-fields

Populate Craft fields with dynamic data using the power of Twig.
Other
147 stars 11 forks source link

Accessing fields within same matrix block #47

Closed tigerchick closed 1 year ago

tigerchick commented 2 years ago

Hi, is it possible to access fields that share a matrix block with a dynamic field? I know it's possible to access fields in the same entry (using element or element.owner when within a matrix block).

I have a matrix block: Within the matrix block are two fields: a super table field (with an entry field inside it) and a dynamic checkbox field. I want the dynamic field to be populated with values derived from the supertable>entry field.

tigerchick commented 2 years ago

After some experimenting I discovered that it is possible using the element variable (which when used within a matrix block will allow us to query the matrix block itself). Using element.owner would allow us to query the entry. Solved!