Hey guys!
I am having a question, again…
Expected behavior
I have the following model:
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
import { Schema, Document, model} from 'mongoose';
interface IItem extends Document {
related_user_id: Schema.Types.ObjectId,
note_type: number,
}
// This section contains the properties of your model, mapped to your collection's properties.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const schema = new Schema({
'related_user_id': { type: Schema.Types.ObjectId, ref: 'user' },
'item_type': Number,
}, {
timestamps: false,
});
export default model<IItem>('items', schema, 'Items');
As of today, I created “smart fields” that actually translate the item_type (enum) constants to an understandable string as well as the foreign key/id which gets remplaced by the name of the user.
The issue is that I would like to go further on this and, when an “administrator” (forest admin user) tries to create/update an item, I would like this admin to have a dropdown list available which would contain all the foreign key available for the user_id field (all the ids from another collection, of course visually changed by the name related collection’s user). At the same time (but slightly different), instead of a text input, I would like the admin to have a dropdown with all the item_type
enum values proposed
So, to summarize (on create/update):
- UserID
foreign key objectID
(Text input) → Should become a dropdown list with all the available ids from the user’s collection (if possible, each id proposed should be visually the name of the related user, so it’s easier to understand) - NoteType
enum
(Text input or integer dropdown) → Should become a dropdown list with all the availble enum values transformed into strings (so it’s undrstandable)
Actual behavior
I can’t find a proper way to do it, so I copy/paste user ID from the other collection item
Thanks for your help