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

default discord avatar
zakoul
2 months ago
2

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?

  • discord user avatar
    jesschow
    Payload Team
    last month

    Hey @zakoul - 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.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.