How to create dynamic Tabs

Hi All

I have a requirement to create dynamic tabs based on certain conditions.

I tried below code but is not working.

The foreach in choose section is not returning the list.

{
a!localVariables(
local!selectedTab: 1,
local!names: {"1", "2", "3"},
{
a!buttonArrayLayout(
buttons: {
a!forEach(
items: local!names,
expression: a!localVariables(
local!modified,
a!buttonWidget(
label: "Tab1 "&fv!item,
saveInto: {a!save(local!selectedTab, fv!item)},
size: "SMALL",
style: if(local!selectedTab = fv!item, "PRIMARY", "LINK")
),
)
)
}
),
{
choose(
local!selectedTab,
a!forEach(
items:local!names,
expression: a!localVariables(
a!forEach(
items: {1},
expression:{
a!textField(
label:"Enter data",
),

},
)
)
),
)
}
}

)
}

  Discussion posts and replies are publicly visible