Search code examples
reactjsadmin-on-rest

How to use the property of an object as a source in the admin-on-rest?


my friends. I want to add a field associated with another resource like here: https://marmelab.com/admin-on-rest/Tutorial.html#relationships

But my problem is that field with id of other resource contain in object:

{
"id": 1,
 ....,
 user: {
     id: "12313123"
 }
}

What can I do in this situation? I already understand that I can create my own "Filelds", but how can I create my own "ReferenceField"? I need that "source" property contain something like this:

       <ReferenceField label="User" source="user.id" reference="users">
            <TextField source="name" />
        </ReferenceField>

Solution

  • It was very simple. It's really work like source="user.id", but when I maked this question I just thought that it will be impossible, so it work like I thought it must work)))