Change search to dropdown in a releated data collections

Hey Team,

We have a relation between 2 collections. If on UI we want to connect it we could do this via search field as on the image:

Is it possible to show available data in dropdown before we search for it? The reason is that we will have about 10 rows of some collection and it will be easier to use it as a dropdown.

1 Like

Hi there @Bojan_Antonijevic :wave:t3:

Switching your layout editor on and going to the features field settings, you should able to set a different Edit widget.

In your case, you’d want to use the belongsTo Select instead of the belongsTo Typeahead.

Note however that you won’t be able to search on the dropdown options here.

I hope this helps!

1 Like

Thank you for the quick replay @anon20071947,

But when we select any relationship we could not enable ‘Filtering enabled’ or see edit or display settings below.

Screenshot 2020-11-02 at 13.21.03

What could be the reason? :thinking:

Hi @Bojan_Antonijevic,

Could you please share with us the model definition of the model that holds the features relationship?

Hi @anon37102731,

Thank you for a jump in.

UsersModel:

Users.belongsToMany(models.features, {
      through: 'user_features',
      foreignKey: 'user_id',
      otherKey: 'feature_id',
});

FeaturesModel:

Features.belongsToMany(models.users, {
        through: 'user_features',
        foreignKey: 'feature_id',
        otherKey: 'user_id',
        as: 'Accounts'
      }
);

If I use hasMany in UsersModel this error appear:

@Bojan_Antonijevic unfortunately this is an hasMany creation widget you’d like to edit and this one is not customizable as is.

However if that’s something that might be useful for you, I’ll log you need for future prioritization.

Best regards,

2 Likes

Thank you for the info and help guys. @anon37102731, @anon20071947

Best regards