Designing a schema for content editors to select project names

8 replies
Last updated: Feb 8, 2022
Hi everyone! I’m trying to design a schema that will accept data from a source system and allow our content editors to make a choice as to which piece of data to show on our front-end website.
For example, I have a document type called Project. In our source system, a project can have a short name, a long name and an alias. For each project in the source system, I want to push all three fields into each Project document in Sanity to be read-only and have the content editors decide which version of the project name will be published to the website.
If none of the above meet the requirements, then they can choose an “Other” field that can be selected.

Attached is a sketch of what I had in my head from a UI perspective. Has anyone tried something similar? I’m presuming it’ll require a custom input component. Any tips for making this as simple as possible from a schema/UI perspective? Thanks!
Feb 7, 2022, 10:02 PM
Hey User! Seems totally possible. This is effectively a string field with a few tweaks: 1. It's getting the first three radio options from an external source and 2. It's got a single input field that's pretty much just a radio option with a
<TextInput>
primitive .
You're correct in that you'll need to use a custom input component here. If you're having trouble conceptualizing it, I can mock up one that has similar functionality.
Feb 7, 2022, 10:14 PM
Thanks
user M
that certainly seems simple. Schema wise, I couldn’t find an example of dynamically defining the list of strings. Is that what you’re suggesting?
Feb 7, 2022, 10:18 PM
Correct! I wrote a guide a few months ago that can take you through dynamically getting list options.
Feb 7, 2022, 10:23 PM
Wonderful, I’ll take a look! Thanks again!
Feb 7, 2022, 10:25 PM
You're welcome!
Feb 7, 2022, 10:26 PM
+10 points for great looking excalidraw wireframes!
Feb 7, 2022, 10:32 PM
Thanks
user U
I only discovered it recently but I’m loving it!
Feb 7, 2022, 10:38 PM
user N
I never even knew about it. Super cool!
Feb 8, 2022, 2:44 AM

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?