Fields define the shape of the content and the user input. There are many types of fields each with its own input and type.
Although some fields have more properties here is a list of common ones that are used.
isTitle
isTitle
can be used to denote which field represents the title of the document. The field set with isTitle=true
is what is displayed in the CMS list view page.
Make sure the following is true when using isTitle
collections.fields
or collections.templates.fields
)required
is set to trueisTitle
export default defineConfig({//...schema: {collections: [{name: 'posts',label: 'Blog Posts',path: 'content/posts',format: 'mdx',fields: [{type: 'string',label: 'Title',name: 'title',isTitle: true,required: true,},// ... other fields],},],},})
isBody
isBody
can be used for "mdx"
, "markdown"
, and "md"
formats. The field used for isBody = true
must have type string
or rich-text
. When isBody
is true it will save that field to the body of the document.
isBody
export default defineConfig({//...schema: {collections: [{name: 'posts',label: 'Blog Posts',path: 'content/posts',format: 'mdx',fields: [{type: 'rich-text',label: 'Body of post',name: 'body',isBody: true,},//... Other fields],},],},})
ui.min
and ui.max
ui.max
only takes effect on object
field types with list: true
specified. It also isn't compatible with object
field types using templates
. It disables the add button in the editor once at least the given number of elements have been added.
{type: "object",label: "Object List",name: "objectList",list: true,ui: {max: 3,},fields: [{//...},]}
ui.min
will ensure that once the specified minimum number of items is added (ex: 3 in the example), users will not be able to remove items if there are only the minimum number of items.
It can apply to all field types with list list: true
specified, provided they appear as a list in the editor. Specifically, this is the:
{type: "string",label: "Llamas",name: "llamas",list: true,ui: {min: 3,}}
Last Edited: September 12, 2024
© TinaCMS 2019–2024