Multi select drop down with multiple supabase tables

I have two tables. One named "locations" and the other one named "menu_assignments". They are linked together with a foreign key that links the locations id to a location_id in the menu_assignments table. That basically assigns a menu to a location and it can have multiple menus assigned. What I want is to have a multi-select drop down that allows the user to assign a location to a menu by adding the location id and the menu id to the menu_assignments table. That table consists of just a menu_id and the foreign key location_id. The drop down needs to show the locations that are assigned to the menu in the initial drop down values and then also the locations that are not assigned in the drop down list so that the user can add the location. I understand how to map the list of locations to the drop down list but how do I show the ones that are already assigned? I can create a view that would show the assigned locations but how do I show that in the initial drop down?

10 replies