Issue with adding title and subtitle to a column in Sanity.io
I can see the issue! When you define an array in Sanity, the of property should contain object types, not just plain field definitions. You're defining fields like you would in a document or object type, but array members need to be wrapped in an object type structure.
Here's the corrected version:
export default {
title: 'Columns',
name: 'columns',
type: 'array',
of: [
{
type: 'object',
fields: [
{
name: 'columnTitle',
type: 'string',
title: 'Title'
},
{
name: 'columnSubTitle',
type: 'string', // Changed from 'subTitle' unless you have a custom type
title: 'Subtitle'
},
{
name: 'columnImage',
type: 'image',
title: 'Image'
},
],
},
],
};The key changes:
- Wrapped everything in an object type: The
ofarray should contain object definitions that have atype: 'object'and afieldsarray - Added the
fieldsproperty: Your title, subtitle, and image fields go inside thefieldsarray of the object - Fixed the subtitle type: Changed
type: 'subTitle'totype: 'string'(unless you have a customsubTitletype defined elsewhere)
The way you had it, Sanity was treating each item as a separate type that could be added to the array (like how block content arrays can have different types of content). But what you want is a single object type that contains all three fields together.
Now when you add an item to the array, you'll get a single object with all three fields (title, subtitle, and image) that you can fill in. The image worked before because image is a valid standalone type, but string fields need to be part of an object structure within arrays.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.