#Can you check a slug in a field condition?

11 messages · Page 1 of 1 (latest)

harsh snow
#

We want to show a specific group of fields depending on our collection, so we thought it might be great to check the slug of the collection in admin:condition. Is this possible?

fallow kernel
harsh snow
#

Yes! Great! Then we'll find a way! Thank you!

harsh snow
#

this will not work

surreal venture
#

@harsh snow under the hood Payload slugifies the slug, so I believe you would check for data.slug === 'event'. You can console log the entire data object to see what it has attached to it as well!

harsh snow
#

even though I do it like this it won't neither log nor hide the group field I'm trying to hide

harsh snow
#

okay seems like data.slug is a falsey value because if I check for data.slug it returns false, I assume I need to have a field that is called slug in my collectionConfig to make this work? Is there any other way to check for the slug of the collectionConfig?

surreal venture
#

Is this an abstracted field that you are using in multiple collections? If that is the case, I would thread through the collection as a string all the way to the abstracted field!

#

Or even if you are using an abstracted field inside a block, then require the block to be passed the collection string, and thread/pass that down to the field as another argument 👍