tlee-pb
1
Builder content link: Builder.io: Visual Development Platform
Builder public api key: 1d8ecee591ac4358befb8fe998100548
What are you trying to accomplish
I like to add
{
name: 'card',
type: 'reference',
model: 'blog-detail',
showIf: "options.get('modelType') === 'blog-detail'",
},
under a list
{
name: 'modelType',
friendlyName: 'Post model type',
type: 'string',
enum: ['blog-detail', 'event-detail],
defaultValue: 'blog-detail',
},
{
name: 'list',
type: 'list',
Content.',
subFields: [
{
name: 'card',
type: 'reference',
model: 'blog-detail',
showIf: "options.get('modelType') === 'blog-detail"'
},
{
name: 'card'
type: 'reference',
model: 'event-detail',
showIf: 'options.get("modeType") === "event-detail"'
]
but doing so, would only create “no editable fields” like below.
Screenshots or video link
video link
Code stack you are integrating Builder with
NextJs
tlee-pb
2
I make it sort of work by the following:
{
name: 'modelType',
friendlyName: 'Post model type',
helperText: 'Please refresh the page after changing the model type to see the change in the preview.',
type: 'string',
enum: Object.entries(RELATED_CONTENT_MODEL_TYPES).map(([key, value]) => ({ label: value, value: key })),
defaultValue: 'blog-detail',
},
{
name: 'listBlog',
type: 'list',
showIf: "options.get('modelType') === 'blog-detail' && options.get('enableManualSelection') === true",
helperText: 'You can manually select the cards to display in the Related Content.',
subFields: [
{
name: 'card',
type: 'reference',
model: 'blog-detail',
meta: {
title: 'Blog Detail',
},
}
],
},
{
name: 'listEvent',
type: 'list',
showIf: "options.get('modelType') === 'event-detail' && options.get('enableManualSelection') === true",
helperText: 'You can manually select the cards to display in the Related Content.',
subFields: [
{
name: 'card',
type: 'reference',
model: 'event-detail',
meta: {
title: 'Event Detail',
},
}
],
},......
but there are a lot of repeated code. Is there a way I can bind all the list to modelType?
so, I don’t have to create multiple list type?