react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Add support to specify field other than id for ReferenceInput

Open diimpp opened this issue 8 years ago • 6 comments

Is your feature request related to a problem? Please describe. When using custom optionValue for SelectInput as shown bellow

<ReferenceInput label="Language code" source="language_code" reference="languages">
    <SelectInput optionText="name" optionValue="code" />
</ReferenceInput>

ReferenceInput will use code to make requests to retrieve resource, which is undesired behaviour.

I'm using ReferenceInput inside Filter and I need to provide custom optionValue for filter search, while keeping id for ReferenceInput

Describe the solution you'd like Add new property on ReferenceInput to support custom identificator

<ReferenceInput optionValue="id">

https://stackoverflow.com/questions/51021661/react-admin-using-field-other-than-id-for-referenceinput

Plus I've some extra weird behaviour, react-admin returns warning like Warning: Missing translation for key: "https://localhost:8443Èze is not a valid URL." Where Èze is a resource name, when <SelectInput optionText='name' optionValue='name'/> is used.

P.S. I'm using react-admin via api-platform/admin.

diimpp avatar Aug 03 '18 13:08 diimpp

Already answered on the stackoverflow question you linked

djhi avatar Aug 04 '18 10:08 djhi

That's why it's a feature request ;)

Unless I'm mistaken, to reimplement ReferenceInput and ReferenceInputController with ability to specify field for Reference and field for Filter will require to maintain my own version of this two files inside a project? That's a crazy overhead for so simple use case.

It's a quite a general purpose use-case, I think it should be solved in the core.

diimpp avatar Aug 04 '18 10:08 diimpp

Also related: #2022

fzaninotto avatar Aug 06 '18 08:08 fzaninotto

Is anything happening with this?

trsteel88 avatar Dec 04 '18 14:12 trsteel88

I'd love to have this feature too

alixdeschamps avatar May 20 '20 09:05 alixdeschamps

We're not going to implement it. Do the mapping with your id field in your dataProvider.

fzaninotto avatar May 20 '20 11:05 fzaninotto