Currently, I have a global type which has two tabs. Each tab has the same fields down to the name.
export const foo: GlobalConfig = {
slug: 'foo'
fields: [
{
type: 'tabs',
tabs: [
{
label: 'Tab One',
description: 'description'
fields: [
{
type: 'text',
name: 'bar',
}
]
},
{
label: 'Tab Two',
description: 'description'
fields: [
{
type: 'text',
name: 'bar',
}
]
}
}
]
}
When I update data for Tab One -> 'bar' field then the Tab Two -> 'bar' field shows the same data and vice versa.
Is there a way to have two tabs with same named fields that do not mirror each others data? I'd like to keep the same name because then I can keep the shape/labels/etc of each set of fields in a constants file.
Thanks for your help!
Arg per usual I did troubleshooting for awhile then asked a question and figured it out right after asking.
Some (maybe all) fields including
tabs
has a property named
name
that acts as the unique identifier for that field. When using two tabs with identical field names the data mirrors each other as described because there was no
name
set on
tabs
to make each distinct.
Add distinct
name
field to each tab as such:
{
type: 'tabs'
tabs: [
{
name: 'foo',
label: 'Foo'
},
{
name: 'bar',
label: 'Bar'
}
]
}
Giving each tab it's own unique name will result in the data beneath it being nested under that identifier.
Star
Discord
online
Get dedicated engineering support directly from the Payload team..