Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Condition inside block - how to access parent data inside block?

default discord avatar
zakoul2 years ago
1

When using conditions inside blocks, I can use siblingData to get data on the same hierarchy level - so far so good. When I need to access parent data (Think: a global "Show Buttons"-checkbox in a Grid component built with an Array Field in Payload) I would have to use data - unfortunately, this gives me the full page data, with which it's extremely difficult (and inefficient) to retrieve the right block from the array.



Is there any way to filter the "data" attribute only to data inside the block, but not on the same level as with siblingData?



Condition inside block - how to access parent data inside block?

  • default discord avatar
    jessrynkar2 years ago

    Hey

    @133357986616836096

    - there isn't a built in way to do this currently but you could pull in both data and siblingData, then use the siblingData.

    id

    to find your active block from the full data.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.