I have a content field requires at least 1 block.
I want to save our editors' effort by providing a default value for it, but defaultValue is not working as I expected.
Found the answer myself.
{
name: 'content',
label: false,
type: 'blocks',
minRows: 1,
maxRows: 1,
blocks: [
{
slug: 'content',
labels: {
singular: 'Content',
plural: 'Content Blocks',
},
fields: [
{
name: 'richText',
type: 'richText',
}
]
}
],
defaultValue: [
{
richText: [{ children: [{ text: '' }] }],
blockType: 'content',
},
],
},
It's really interesting that writing/asking the question itself can give me the answer.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.