Skip to content
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

Supported nested objects in field & input source with dotted notation #19

Open
vaizki opened this issue Nov 21, 2022 · 3 comments
Open

Comments

@vaizki
Copy link

vaizki commented Nov 21, 2022

I have a nested object in my record, like this:

{
  id: "abcdef",
  info: {
    tree: {
       x: 1,
       y: 2
    }
  }
}

Now if I use the JSON view components and put source="info.tree" it doesn't work as the component looks for record[source]. The React Admin native fields and inputs use lodash to resolve nested location:

import get from 'lodash/get';
...
const value = get(record, source);

Could you incorporate this into the field and input?

@vaizki
Copy link
Author

vaizki commented Nov 22, 2022

Just noticed that lodash/get was there before the RAv4 update release, so what was the reason for getting rid of lodash here?

@fkowal
Copy link

fkowal commented Feb 12, 2024

commented in the MR

const record = useRecordContext(props);

is a pattern that is used in react admin codebase

it's more powerful, it would allow <FunctionField render={(rec) => <JsonField source="newfield" record={{newfield: rec.x.y.z}} />>

so this is a key missing piece because JsonField doesn't support this (passing props to useRecordContext

@fkowal
Copy link

fkowal commented Feb 12, 2024

@MrHertal ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants