Hi @mathieuh,
Array of references are currently not supported in smart action forms.
However, as a workaround if you are using v8, I think you should be able to achieve a similar result without the reference
using hooks (load
& change
).
Eg. If you have a small number of suppliers (So a dropdown is enough to search through), something like
{
actions: [{
name: 'SmartActionExample',
type: 'bulk',
fields: [{
field: 'suppliers',
type: ['Enum'],
isRequired: false,
}],
hooks: {
load: async ({ fields }) => {
const allSuppliers = await users.findAll();
fields.find(f => f.field === 'suppliers').enums = allSuppliers.map(
u => `${u.name} | ${u.id}`
);
return fields;
}
}
}
If you have a bigger number of suppliers, something like this maybe?
{
name: 'SmartActionExample',
type: 'bulk',
fields: [{
field: 'supplier 1',
type: 'Number',
reference: 'users.id',
isRequired: false,
hook: 'onSupplierChange',
}],
hooks: {
change: {
onSupplierChange: async ({ fields }) => {
fields.push({
field: `supplier ${fields.length + 1}`,
type: 'Number',
reference: 'users.id',
isRequired: false,
hook: 'onSupplierChange',
});
return fields;
}
}
}
}
This is just a workaround though (So it is far from perfect from what you might expect). To be more explicit, handling Array of references is currently not supported since we don’t have widgets
that allow such selection.
Still, I’ll also push this thread as a feature request in our product board.