# Dropdown(s) of constants/foreign keys on create/update from UI

**URL:** <https://community.forestadmin.com/t/dropdown-s-of-constants-foreign-keys-on-create-update-from-ui/1835>\
**Category:** Help me!\
**Created:** [February 11, 2021, 8:18pm UTC](https://community.forestadmin.com/t/dropdown-s-of-constants-foreign-keys-on-create-update-from-ui/1835 "2021-02-11T20:18:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emixam23](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/emixam23/32/1350_2.png) [@Emixam23](https://community.forestadmin.com/u/Emixam23)\
**Post date:** [February 11, 2021, 8:18pm UTC](https://community.forestadmin.com/t/dropdown-s-of-constants-foreign-keys-on-create-update-from-ui/1835/1 "2021-02-11T20:18:39Z")

</div>

Hey guys!

I am having a question, again… 🙂

## Expected behavior

I have the following model:

```javascript
// 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 🙂

---

<div class="post-metadata">

**Author:** ![remi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/remi/32/334_2.png) [@remi](https://community.forestadmin.com/u/remi)\
**Post date:** [February 12, 2021, 11:11am UTC](https://community.forestadmin.com/t/dropdown-s-of-constants-foreign-keys-on-create-update-from-ui/1835/2 "2021-02-12T11:11:57Z")

</div>

Hello Maxime!

Before answering your question, I would like to be sure I understand your two requests correctly.

1. You have a collection `Items` which is linked to a user via the `related_user_id` field, and you want to be able to select this linked user in a dropdown when creating/updating a record on it ?

2. I’m not sure about that one, because you talk about note\_type being the enum, and item\_type being a enum, which in fact you both declare as Numbers. Could you explain this scenario more precisely please? 🙂

Have a nice day!

---

<div class="post-metadata">

**Author:** ![Emixam23](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/emixam23/32/1350_2.png) [@Emixam23](https://community.forestadmin.com/u/Emixam23)\
**Post date:** [February 14, 2021, 8:51pm UTC](https://community.forestadmin.com/t/dropdown-s-of-constants-foreign-keys-on-create-update-from-ui/1835/3 "2021-02-14T20:51:30Z")

</div>

Hello 🙂

Yes that’s it. Currently, when i start to type the id, the choice is getting proposed as dropdown “emixam23” by example, but i still have to start to type the begining of the id

Sorry but I am working so much these days and as I “anonymize” my code, I just have misstyped… sorry! NoteType is a mistake of mine, it’s ItemType 🙂

Thanks

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [February 15, 2021, 8:46am UTC](https://community.forestadmin.com/t/dropdown-s-of-constants-foreign-keys-on-create-update-from-ui/1835/4 "2021-02-15T08:46:00Z")

</div>

Hi @Emixam23 👋 what I understand, you need to define a different edit widget.  
See the [documentation](https://docs.forestadmin.com/documentation/reference-guide/fields/customize-your-fields) to know oh to go to field settings. And select a dropdown widget to achieve your goal.  
Let me know if it help.

---

<div class="post-metadata">

**Author:** ![Emixam23](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/emixam23/32/1350_2.png) [@Emixam23](https://community.forestadmin.com/u/Emixam23)\
**Post date:** [February 17, 2021, 10:12pm UTC](https://community.forestadmin.com/t/dropdown-s-of-constants-foreign-keys-on-create-update-from-ui/1835/5 "2021-02-17T22:12:21Z")

</div>

Hey!

It worked, thanks 🙂

Max,
