Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Clearing a sibling field in a document based on radio option selection

5 replies
Last updated: May 23, 2024
Hello, how can I go about clearing a sibling field in a document if a radio option is selected? For example
May 23, 2024, 6:47 PM
I've played around with custom components, but I'm not having any luck setting or clearing a custom input that's external to the input in question.
May 23, 2024, 6:50 PM
You would need to use the
useClient
hook inside of your component to perform a patch on the field you’re looking to change. Just hijack the
onChange
and perform the patch before you perform the default
onChange
May 23, 2024, 7:01 PM
Do you have an example of how I would do this?
May 23, 2024, 7:27 PM
Actually, I got it! Thanks!
May 23, 2024, 7:39 PM
Oh great!
May 23, 2024, 7:57 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?