I am trying to add a dropdown to the smart action form that shows a list of names of any model, in this example rooms. In the handler method I then want to assign the selected room to a house. I only find examples where the “Room” is mapped onto an enum field, using the rooms name. How can I forward the room ID instead to the handler method, but display the room name in the dropdown?
For example, I might have a house with 3 bedrooms, so every room name is “Bedroom”. Since “name” is not a unique identifier, it is not a reliable way to look up the model in the database.
I would like to do something like mapping the rooms to a label/value pair. The given example only shows {object Object} in the dropdown for rooms.
Normally you can do something like on forest-express-sequelize:
{
field: 'room',
type: 'String', // Or number if your id is a Number
// Notice this line, it will tell us that this is referencing actually another collection
// It should be `name_of_my_collection.primary_key_name`
reference: 'room.id',
isRequired: true
},
But that creates the normal searchable relation field, which I find a bit inconvenient if we only have like 5 instances for example. Changing the type to Enum does not work in that case. Can I modify the field from typeahead to dropdown in the smart action form as well somehow?
And maybe you can quickly point me to another thing: When I add a “search” key to a field to pre-filter the resources, I get “The search on the referenced collection is not authorized.”. From what I found I have to allow it somewhere in the settings, but I could not find the right place.