Hello @nike1v,
I suppose this is a follow up to the previous discussion we had about dynamic forms.
I tried to implement something in the way you have described, it is rudimentary but it seems to work fine.
Adding and removing elements from the list updates the form as expected:
=>
Here is the snippet for the action:
.addAction("Dynamic form", {
scope: "Single",
form: (context) => {
const form = [
{
label: "Orders",
type: "NumberList",
widget: "Dropdown",
isRequired: true,
options: async (actionContext) => {
const orders = await actionContext.dataSource
.getCollection("orders")
.list({}, ["id"]);
return orders.map(({ id }) => id);
},
},
];
if (context.formValues['Orders'] && context.formValues['Orders'].length > 0) {
context.formValues['Orders'].forEach(order => {
form.push({
label: `Check this for order#${order}`,
type: 'Boolean',
widget: 'Checkbox',
})
})
}
return form;
},
execute: async (context, resultBuilder) => {
...
},
})