object
Typetype ObjectField = {label: stringname: stringtype: 'object'list?: boolean// `fields` OR `templates` may be provided, not bothfields?: Field[]templates?: Template[]/** Customize the default "_template" key that gets setin a document to identify a block-type.Only applicable when list: true **/templatesKey?: string// See https://tina.io/docs/extending-tina/overview/ for customizing the UIui?: {// Whether or not the Visual Selector is enabled. See https://tina.io/docs/editing/blocks/#adding-a-visual-block-selector-experimentalvisualSelector?: boolean,// defaultItem can only can be used when {list: true}defaultItem?: Record<string, any> | () => Record<string, any>,itemProps?(item: Record<string, any>): {label?: string}}}
Tina will generate the appropriate component depending on the configuration provided.
{label: "Testimonial",name: "testimonial",type: "object",fields: [{label: "Author",name: "author",type: "string"},{label: "Role",name: "role",type: "string"},{label: "Quote",name: "quote",type: "string",ui: {component: "textarea"}}]}
{label: "Testimonials",name: "testimonials",type: "object",list: true,ui: {itemProps: (item) => {return { label: `${item?.author} ( ${item?.role} ) ` }},defaultItem: {author: "Judith Black",role: "CEO",quote: "Lorem ipsum dol..."}},fields: [{name: "author",// ...},{name: "role",// ...},{name: "quote",// ...}]}
Number, boolean, datetime and rich-text field types can be used in this way to add list options to the TinaCMS editor.
Reference field types can be used in this way to create a list of references.
{label: "Author List",name: "authorList",type: "object",list: true,fields: [{label: 'Author',name: 'author',type: 'reference',collections: ['author'],},]}
{label: "Page Blocks",name: "pageBlocks",type: "object",list: true,templates: [{label: "CTA",name: "cta",fields: [...]},{label: "Testimonial",name: "testimonial",fields: [...]}]}
Last Edited: September 12, 2024
© TinaCMS 2019–2024