I'm using admin-on-rest. What a great framework ! It is working quite well for my flat resources.
I'm retrieving a list of projects /projects
. I've implemented a ProjectEdit View to edit a given project /projects/:id
export const ProjectEdit = props => {
const projectId = props.match.params.id;
return (
<Edit title={<ProjectTitle />} {...props}>
<TabbedForm>
<FormTab label="Project">
<DisabledInput source="id" />
<TextInput source="name" />
</FormTab>
<FormTab label="Companies">
// WHAT Should I put here to edit my companies list ???
</FormTab>
</TabbedForm>
</Edit>
);
};
I'd like to implement a new tab from which I'd be able to add / remove companies from my project.
GET /projects/:id/companies
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 2,
"name": "My Company"
}
]
}
POST /projects/:id/companies
DELETE /projects/:id/companies/:company_id
I've tried to use a ReferenceManyField
but I'm unable to configure it since my API requires a custom GET. My projects don't have any reference to companies. I can't find any example on how to perform it.
Any clues please ? :)
EDIT1: I'm able to display a list of my project's companies using @malisbad answer. But I'm still not able to display it for edition (eg: Using a ReferenceArrayInput + SelectArrayInput)