I'm quite new to Sanity and I'd like to know how to do this.
I'm adding items using the following schema
defineField({
title: 'Ingredients',
name: 'ingredients',
type: 'array',
of: [
{
type: 'object',
fields: [
{
name: 'ingredient',
title: 'Indredient',
type: 'reference',
to: [{ type: 'ingredient' }],
validation: Rule => Rule.required().error('Ingredient is required.')
},
defineField({
title: 'Amount',
name: 'amount',
type: 'number',
validation: Rule => Rule.required().error('Amount is required.')
}),
defineField({
title: 'Unit',
name: 'unit',
type: 'string',
options: { list: [...] }
})
],
}
]
}),
This works fine, but when adding the entity in Sanity studio it only shows the last item in the object like this
How do I get this to display with a concatenation of the object values?
You need to add a list preview after the fields array. You can find more help in Sanity docs here: https://www.sanity.io/docs/previews-list-views