👀 See Sanity in action: Watch product demo now →

Creating a Field for an Image or String - Error: Invalid item type: "[object Object]"

4 replies
Last updated: Jun 27, 2022
im trying to build a field that would either be an image OR just a string (for css style properties)but i get this error:

Error: Invalid item type: "[object Object]". Default array input can only contain objects (for now)
Check the browser's console for details.
so what's the best way to allow an image or string for a field
Jun 27, 2022, 6:26 PM
I do this for picking a video -- no video, Vimeo or YouTube. They are just address fields instead of doing anything "fancy" like using the plugins and it lets me pivot really easily in the GROQ query
Jun 27, 2022, 6:31 PM
It sounds like you’re encountering the second limitation on arrays . The solutions above should work, as would using an object containing a string (rather than only a primitive string).
Jun 27, 2022, 6:44 PM
thanks for the help guys. I'm going to give
user R
solution a try
Jun 27, 2022, 7:36 PM
ya this works perfectly; thanks
user R
Jun 27, 2022, 8:30 PM

Sanity.io – build remarkable experiences at scale

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