Is there any way to use a different reference field (other than id
) for a ReferenceInput
?
For example:
I have a languages
resource, which I want to populate using a language_code
field.
Note, I don't want to use the id
field of languages
, I want to use the code
field.
I have managed to get it to work by using the following:
<ReferenceInput
label="Language code"
source="language_code"
reference="languages"
>
<SelectInput optionText="name" optionValue="code" />
</ReferenceInput>
The only problem with this is that:
After selecting a language from the select input, the ReferenceInput
tries to fetch the resource using the code
field rather than the id
field, which returns a 404 error.
id
field instead of thecode
field ? – Pyosiscode
field (I assume because theoptionValue
is set tocode
so it populates theReferenceInput
with the code). So it fetcheslanguages/en
rather andlanguages/1
. This fails because thelanguages
endpoint expects anid
in the URL and not a code. – Stillman