-
Hei, Thank you for an awesome project Dev Team! I'm was just curious if anyone ever did it and how to (if possible). I would like to re-use the default crud Edit page, but I've not figure out how to change GET resource url to a custom one, and to save form with a different URL, but the same set of data. For example, user profile page (using strapi as a backend):
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hey @w20k , Here is how you can do it:
const { formProps, saveButtonProps, onFinish } = useForm({
resource: "/users/me",
id: "", // I am not sure this will work, please let me know if it does not
});
const { mutate } = useCustomMutation();
const handleOnFinish = (values) => {
mutate({
url: `${API_URL}/users/me/profile`,
method: "patch",
values
});
};
return (
<Edit saveButtonProps={saveButtonProps}>
<Form {...formProps} onFinish={handleOnFinish} layout="vertical">
<Form.Item label="Name" name="name">
<Input />
</Form.Item>
<Form.Item label="Surname" name="surname">
<Input />
</Form.Item>
</Form>
</Edit>
); I haven't had a chance to try the code but I believe it will work. |
Beta Was this translation helpful? Give feedback.
-
Hey @omeraplak, Thank you for your suggestion! For some reason, haven't found the cause yet, but if I specify the URL in Maybe it's also good to mention that I have a different URL for the User Profile page, in my case it is '/profile' and to change organisation it is '/profile/organisation' (so, to pages with custom form requests). I will double check with a clean example and will let you know how it went! Once again, thank you for you help!!! |
Beta Was this translation helpful? Give feedback.
Hey @w20k ,
We had previously discussed offering this as a built-in feature with the core team and had decided it was unnecessary. This is asked from time to time by the community, so perhaps adding it to the FAQ section would be a much better idea. If you want to do this, your PR will be warmly welcomed.
Here is how you can do it: