I am using Edit
and SimpleForm
from react-admin
. How do I create a custom form to allow customised action
and type
on submit?
App.js
<Resource name="category" list={CategoryList} edit={CategoryEdit} />
index.js
<Edit actions={<CategoryEditActions />} title={<CategoryTitle />} {...props} >
<SimpleForm>
<DisabledInput source="id" />
<DisabledInput source="code" />
<TextInput source="name" />
</SimpleForm>
Here the api call would be /category/:categoryId
with PUT
request. I want to modify url to /category/:categoryId/test
with method as POST
. Is there any way to customize this?
I have handled this in my CustomDataProvider -
case UPDATE:
if(resource === 'category'){
options.method = 'POST';
url = `${apiUrl}/${resource}/${params.id}/test`;
} else {
options.method = 'PUT';
url = `${apiUrl}/${resource}/${params.id}`;
}
break;
Is there any other way to handle it?