How to reference by a field other than id?

Viewed 22

I have a <ReferenceField /> which needs to link using a field other than the id on the referred record.

<ReferenceField source="provider_id" reference="provider" link="show">
  <TextField source="display_name" />
</ReferenceField>

The field on the current record is provider_id, but in the provider table the column I need is called short_id not id, which is different.

Is this possible in React Admin?

1 Answers

Found a workaround using <ReferenceManyField />:

<ReferenceManyField
  source="provider_id"
  target="short_id"
  reference="provider"
>
  <SingleFieldList>
    <TextField source="display_name" />
  </SingleFieldList>
</ReferenceManyField>
Related