Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

How to return dynamic list values for a string field using a function in Sanity

2 replies
Last updated: May 27, 2020
Hello!Have anybody got any experience with returning dynamic
list
values for a string field using a function?Is this possible somehow?


{
  name: 'mySelectField',
  type: 'string',
  options: {
    list: (doc, options) => { return MY_VALUES; }   //  <-- Like this!?
  }
}
TLDR; I'd like to refer to inlined objects in array in the same document using their
_key
property, and populating the string dropdown with the existing values.
May 27, 2020, 6:21 PM
I can see how this could be useful, but it isn't possible with the built in options. That means you'd have to build a custom component for it.
May 27, 2020, 8:48 PM
I can see how this could be useful, but it isn't possible with the built in options. That means you'd have to build a custom component for it.
May 27, 2020, 8:48 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?