Issue with adding title and subtitle to a column in Sanity.io
30 replies
Last updated: Dec 6, 2022
H
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
B
Hey Hii
user U
Dec 6, 2022, 11:46 AM
H
Hey!
Dec 6, 2022, 11:47 AM
B
I think you should try doing string instead of "SubTitle"
Dec 6, 2022, 11:47 AM
B
And tell me if it works or not
Dec 6, 2022, 11:47 AM
H
even tho i have a object called
subTitle?
Dec 6, 2022, 11:47 AM
B
Ya, Object name doesn't matter
Dec 6, 2022, 11:48 AM
H
This didnt work
Dec 6, 2022, 11:48 AM
B
Data type is too important
Dec 6, 2022, 11:48 AM
H
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
H
could be a typo somewhere?
Dec 6, 2022, 11:48 AM
B
Is there any specific reason for using array instead of Document?
Dec 6, 2022, 11:49 AM
H
Creating a “Page builder”
Dec 6, 2022, 11:49 AM
H
not really for the entire page, but a section where the user can customize themselves
Dec 6, 2022, 11:50 AM
B
Try doing document like this
Dec 6, 2022, 11:50 AM
H
The purpose of a page builder is a little different of what you sent!
Dec 6, 2022, 11:51 AM
B
Look i just want you to try
Dec 6, 2022, 11:51 AM
H
I tried it, it worked the way
documentshould work
Dec 6, 2022, 11:52 AM
B
So field type as a document is working, right?
Dec 6, 2022, 11:52 AM
H
Yes
Dec 6, 2022, 11:52 AM
B
Okk
Dec 6, 2022, 11:53 AM
B
So did you tried doing some research for array in sanity docs?
Dec 6, 2022, 11:54 AM
H
Found the issue. No worries!
Dec 6, 2022, 12:02 PM
B
Can you pls tell me what was the problem?
Dec 6, 2022, 12:02 PM
B
Much appreciated
Dec 6, 2022, 12:04 PM
H
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
H
had to wrap each string fields inside an object
Dec 6, 2022, 12:05 PM
B
Ohh i see
Dec 6, 2022, 12:06 PM
B
Thanks
user U
Dec 6, 2022, 12:06 PM
H
Any time! Thank you for spending time to help!
Dec 6, 2022, 12:06 PM
B
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.