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

Custom Studio input implementation issue with useFormValue in Sanity

2 replies
Last updated: Jun 21, 2024
Hello all, I am trying to implement a custom Studio input. I have a document where there is an array of objects, and in this objects there is a reference field and a field with the custom component. The idea is to fetch the referenced document and display a select based on some values of that document. The problem I am having is that with
useFormValue
it does not seems as I can identify which object is being rendered. So the component does not know in which object resides or from which object read the reference field. Keep in mind each object migh have different values in that reference field.
Does someone have any idea on how to overcome this?
Jun 20, 2024, 6:12 PM
Your component will receive a
path
array in your
props
. You can slice the last item off of that array to get the parent object. That will contain your sibling field with the reference.
Jun 20, 2024, 8:31 PM
Thank you. Yes, the path prop does the trick!
Jun 21, 2024, 6:45 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?