Issue with adding title and subtitle to a column in Sanity.io

30 replies
Last updated: Dec 6, 2022
Any idea why this isnt working? I can add a image, but not title or subtitle
export default {
  title: 'Columns',
  name: 'columns',
  type: 'array',
  of: [
    {
      name: 'columnTitle',
      type: 'string',
    },
    {
      name: 'columnSubTitle',
      type: 'subTitle',
    },
     {
      name: 'columnImage',
      type: 'image',
    },
  ],
};
Dec 6, 2022, 11:45 AM
Hey Hii
user U
Dec 6, 2022, 11:46 AM
Hey!
Dec 6, 2022, 11:47 AM
I think you should try doing string instead of "SubTitle"
Dec 6, 2022, 11:47 AM
And tell me if it works or not
Dec 6, 2022, 11:47 AM
even tho i have a object called
subTitle
?
Dec 6, 2022, 11:47 AM
Ya, Object name doesn't matter
Dec 6, 2022, 11:48 AM
This didnt work
Dec 6, 2022, 11:48 AM
Data type is too important
Dec 6, 2022, 11:48 AM
export default {
  title: 'Columns',
  name: 'columns',
  type: 'array',
  of: [
    {
      title: 'Title',
      name: 'columnTitle',
      type: 'string',
    },
    {
      title: 'Sub Title',
      name: 'columnSubTitle',
      type: 'string',
    },
    {
      name: 'columnImage',
      type: 'image',
    },
  ],
};
Dec 6, 2022, 11:48 AM
could be a typo somewhere?
Dec 6, 2022, 11:48 AM
Is there any specific reason for using array instead of Document?
Dec 6, 2022, 11:49 AM
Creating a “Page builder”
Dec 6, 2022, 11:49 AM
not really for the entire page, but a section where the user can customize themselves
Dec 6, 2022, 11:50 AM
Try doing document like this
Dec 6, 2022, 11:50 AM
The purpose of a page builder is a little different of what you sent!
Dec 6, 2022, 11:51 AM
Look i just want you to try
Dec 6, 2022, 11:51 AM
I tried it, it worked the way
document
should work
Dec 6, 2022, 11:52 AM
So field type as a document is working, right?
Dec 6, 2022, 11:52 AM
Yes
Dec 6, 2022, 11:52 AM
Okk
Dec 6, 2022, 11:53 AM
So did you tried doing some research for array in sanity docs?
Dec 6, 2022, 11:54 AM
Found the issue. No worries!
Dec 6, 2022, 12:02 PM
Can you pls tell me what was the problem?
Dec 6, 2022, 12:02 PM
Much appreciated
Dec 6, 2022, 12:04 PM

export default {
  title: 'Columns',
  name: 'columns',
  type: 'array',
  of: [
    {
      title: 'Title',
      type: 'object',
      name: 'columnTitle',
      fields: [
        {
          title: 'Title',
          name: 'title',
          type: 'string',
        },
      ],
    },
    {
      title: 'Sub title',
      type: 'object',
      name: 'columnSubtitle',
      fields: [
        {
          title: 'Sub Title',
          name: 'subtitle',
          type: 'string',
        },
      ],
    },
    {
      name: 'columnImage',
      type: 'image',
    },
  ],
};
Dec 6, 2022, 12:05 PM
had to wrap each string fields inside an object
Dec 6, 2022, 12:05 PM
Ohh i see
Dec 6, 2022, 12:06 PM
Thanks
user U
Dec 6, 2022, 12:06 PM
Any time! Thank you for spending time to help!
Dec 6, 2022, 12:06 PM
It was my pleasure
Dec 6, 2022, 12:07 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?