// on the linked class that acts as the selector for the linked class.
// Returns null if no selector is found or the field is not a link.
getLinkSelector(fmClass: string, field: string): string {
- const fieldDef = this.classes[fmClass].field_map[field];
+ let fieldDef = this.classes[fmClass].field_map[field];
+
+ if (fieldDef.map) {
+ // For mapped fields, we want the selector field on the
+ // remotely linked object instead of the directly
+ // linked object.
+ const linkedClass = this.classes[fieldDef.class];
+ fieldDef = linkedClass.field_map[fieldDef.map];
+ }
+
if (fieldDef.class) {
const classDef = this.classes[fieldDef.class];
if (classDef.pkey) {