-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a 'target' field to <ReferenceField> #5581
Comments
Might totally misunderstand your question but you can just put
Creates a request like: /your_resource_in_app/voucherCode/ As far as the error goes: #5054 should have fixed it I think. Maybe update your React Admin? |
Thanks @MicroJackson. You're right, one workaround could be to modify the backend. If I was going to do that, I'd simply create a custom mapping ( Another workaround (to keep the "link" behaviour), would be to use e.g. I'd prefer to continue to investigate adding a re: #5054 - I'm not sure that I'm already on the latest - |
Looking for some guidance on how to proceed (@fzaninotto)) - happy to get my hands dirty if there's interest in including this feature. My initial investigation... ReferenceField - currently calls Two options:
Call Chain ReferenceField calls -> useReference({ reference, id }) react-admin/packages/ra-ui-materialui/src/field/ReferenceField.tsx Lines 87 to 96 in 1e2e575
which calls -> useGetMany(reference, [id]) react-admin/packages/ra-core/src/controller/useReference.ts Lines 43 to 51 in 89ac783
proposed? -> useGetManyReference(resource, target, id, pagination, sort, fiter, referencingResource, options) react-admin/packages/ra-core/src/dataProvider/useGetManyReference.ts Lines 58 to 67 in 89ac783
|
Duplicate of #2022. Please see @fzaninotto answer |
Hi @djhi - thanks for the response. Just one question if you'll humour me. First - agree it's a duplicate.
👍 - No problem. All my records have my records have an
Then why does UPDATE I'll ask Francois over here (if he doesn't mind me posting on old issues): -> #2022 (comment) |
Is your feature request related to a problem? Please describe.
I want to use a
ReferenceField
, to lookup a (single) resource based on a foreign field name (e.g.voucherCode
notid
). HoweverReferenceField
only allows me to use the default foreign fieldid
.I imagine this is a pretty common use case, especially in existing databases.
Please correct me if I'm using the wrong component (or wrongly using the right component!).
Describe the solution you'd like
I'd like
ReferenceField
to behave similarly toReferenceManyField
, in that I can supply a foreign field name to match against (i.e.target={...}
).e.g.
I'd like a
ReferenceField
to support atarget
attribute...... similar to how
ReferenceManyField
already behaves.Describe alternatives you've considered
I've tried using
ReferenceManyField
- which can lookup the field successfully, but throws an error when I return to list view after updating an object (screenshot attached)The text was updated successfully, but these errors were encountered: