Hello @ShortLink,
The problem: Inside subFields (nested Lists), showIf does not accept a function; it only works as a string expression.
The fix: Pass showIf as a template string instead of a function:
// ❌ Won't work inside subFields
showIf: (options) => options.get('Type') === 'fixed'
// ✅ Works inside subFields — pass it as a STRING
showIf: `options.get('Type') === 'fixed'`
Notice the key difference: no wrapping function, just the raw string expression. Builder evaluates it internally.
Here’s how your full Content Model registration should look:
Builder.registerContentType('Sample A', {
fields: [
{
name: 'Slug',
type: 'text',
},
{
name: 'Recommendations',
type: 'list',
subFields: [
{
name: 'Category',
type: 'text',
},
{
name: 'Type',
type: 'text',
enum: ['search', 'fixed'],
},
{
name: 'Options',
type: 'list',
subFields: [
{
name: 'Item',
type: 'text',
},
{
name: 'placeId',
type: 'text',
// ✅ String expression — references the sibling field 'Type'
// @ts-ignore — TS types don't support strings here, but it works
showIf: `options.get('Type') === 'fixed'`,
},
],
},
],
},
],
})
Hope this helps!