✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

How to create an array of objects for ticket prices in an event schema.

3 replies
Last updated: Sep 15, 2023
Im attempting to add a set of prices to an event schema. They will always be the same, but may not all be needed for each event. Is it possible to create an array where i can add items with a title and value without it having to be a reference to a different document?
Sep 15, 2023, 8:47 AM
Sounds like an array of objects :)
Sep 15, 2023, 9:04 AM
Would this be the correct syntax then?

        title: 'Ticket Prices',
        name: 'ticketprices',
        type: 'object',
        fields: [
          {name: 'studentprices', type: 'number', title: 'student Price'},
          {name: 'normalprices', type: 'nubmer', title: 'Normal Price'},
Sep 15, 2023, 9:06 AM
Yup, just lob that into this:

 name : "prices",
 of: [//your code]
Sep 15, 2023, 10:11 AM

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?