Hi there, I'm currently using blocks for a collection type, and I want to add a default value to the Block field so my editors have a default setup to work with.
I already tried something like this:
defaultValue: [
{
blockType: 'registered-block1'
},
{
blockType: 'registered-block2'
},
{
blockType: 'registered-block3'
}
]
But that didn't work :l
Managed to fix it, the default value entries requires a
blockName
as well to work.
For future reference, or anyone else looking for this. the payloadCMS repository has a
test
folder including several setups for Payload.
I managed to find a working example here:
https://github.com/payloadcms/payload/blob/master/test/fields/collections/Blocks/index.tsHey @Derosul are you using typescript? I would imagine it would have complained that you did not give a block name?
Yes, I am using typescript 🙂
DefaultValue is unknown
Interesting! Yep, figured it was the defaultValue. Hmmm I’ll bring this up internally, I imagine we could improve this!
Yes, adding typings should fix questions when it comes to this! in the meantime, using the "test" directory on the payload CMS repo is really helpful when figuring out configs!
Thanks for checking @Jarrod 🙂
Yeah that’s a gold mine for sure haha!
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.