can i load dynamic data to an options field?
the code below doesn't work but i would like to loop on a collection and gets its internal values like this:
fields: [
{
name: 'Facets',
type: 'select',
hasMany: true,
options: [
async () => {
const facets = await payload.find({
collection: "facet",
})
let facet_values = facets.map(function (facet) {
return facet.values;
});
let brands_and_categories = facet_values.map(function (v) {
return {
value: v.name
key, v.id
};
});
return brands_and_categories;
}
],
]}
``
also note that i tried also to set relationship but then couldnt get the values of the 'facets' collection in the select box:
// {
// name: 'Facets',
// type: 'relationship',
// hasMany: true,
// relationTo: 'facets',
// },