This Friday: Hear from Sanity + Vercel experts on AI and better personalization in e-commerce

Can You Show/Hide an Array Item’s “+ Add Item” Option?

2 repliesLast updated: Aug 8, 2022

Hi, in Studio can one show/hide an array item’s “+ Add Item” option? I’d like to prevent shallow duplicates of an item. I know validation rules work after insertion, but maybe? there’s a way to control the list items when one clicks “+ Add Item”. If not, I assume Structure Builder can do it. Thanks!
Hey user K! Are these references to documents? If so, you can use the
filter
option (example here ).
However, if they're objects you will need to use validation to check for duplicates since they can't be dynamically filtered in the schema. You could also create a custom input component.
They’re objects, so maybe I’ll look into custom components. Thanks!

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions