Change field before send to api
Here is my code
Here is my code for my create page, but i want, before sending data to the server, updating the key "clients", i want to change clients which is a string list to a list object like this clients: [{id: string}, ........] where id is the current string
17 Replies
Hi @realdragonma. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
You can modify the
clients
value before submitting the form by using the onFinish
prop of the Form
component. Here's how you can update your code:
In this code, we define a handleFinish
function that transforms the clients
array into the desired format and then calls the original onFinish
function with the updated values. We pass this handleFinish
function to the Form
component using the onFinish
prop.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@214840332943097856> kapa.ai is still learning and improving, please let us how it did by reacting below
complex-tealOP•2y ago
@kapa.ai it doesnt work at all
Let me check the knowledge base for you. One moment! :books:
----------------------
I apologize for the confusion. Based on the information extracts provided, I am unable to troubleshoot the issue with your code. However, I can still guide you on how to use the
refine
framework.
To create a form with refine
, you can follow these steps:
1. Set up your development environment: Prepare your dev environment (https://refine.dev/docs/tutorial/getting-started/prepare-env)
2. Create a refine
project: Creating your refine project (https://refine.dev/docs/tutorial/getting-started/headless/create-project)
3. Run the development server: Running the dev server (https://refine.dev/docs/tutorial/getting-started/headless/create-project)
For more information on using refine
, you can refer to the official documentation (https://refine.dev/docs).
If you still face issues, please provide more context or error messages, and I'll try my best to help you based on the information extracts available.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------2. Prepare your dev environment | refine
Get the dev tools you need
3. Creating your refine project | refine
Launch the refine CLI setup
<@214840332943097856> kapa.ai is still learning and improving, please let us how it did by reacting below
complex-tealOP•2y ago
@kapa.ai
Let me check the knowledge base for you. One moment! :books:
complex-tealOP•2y ago
@kapa.ai
The console.log("ok") isn't log when i click save, how is it possible ?
Let me check the knowledge base for you. One moment! :books:
----------------------
Based on the provided code, you are trying to modify the form data before submitting it to the API. You have created a
handleFinish
function to update the clients
array and then call the original onFinish
function with the updated values.
Here's the code snippet you provided:
This approach should work as expected, as it follows the example provided in the refine documentation (https://refine.dev/docs/api-reference/antd/hooks/form/useForm/#how-can-i-change-the-form-data-before-submitting-it-to-the-api). If you are facing any issues, please provide more context or error messages, and I'll try my best to help you based on the information extracts available.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------useForm | refine
useForm is used to manage forms. It returns the necessary properties and methods to control the Antd Form. Also, it has been developed by using useForm imported from @refinedev/core package.
<@214840332943097856> kapa.ai is still learning and improving, please let us how it did by reacting below
----------------------
I apologize for the confusion earlier. Based on the information extracts provided, I am unable to troubleshoot the issue with your code. However, I can still guide you on how to use the
refine
framework.
To create a form with refine
, you can follow these steps:
1. Set up your development environment: Prepare your dev environment (https://refine.dev/docs/tutorial/getting-started/prepare-env)
2. Create a refine
project: Creating your refine project (https://refine.dev/docs/tutorial/getting-started/headless/create-project)
3. Run the development server: Running the dev server (https://refine.dev/docs/tutorial/getting-started/headless/create-project)
For more information on using refine
, you can refer to the official documentation (https://refine.dev/docs).
If you still face issues, please provide more context or error messages, and I'll try my best to help you based on the information extracts available.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------2. Prepare your dev environment | refine
Get the dev tools you need
3. Creating your refine project | refine
Launch the refine CLI setup
<@214840332943097856> kapa.ai is still learning and improving, please let us how it did by reacting below
complex-tealOP•2y ago
@kapa.ai how many question can i ask you ?
Let me check the knowledge base for you. One moment! :books:
----------------------
You can ask as many questions as you need, and I'll do my best to help you based on the information extracts provided. If you have any questions related to the
refine
framework or any other topic covered in the extracts, feel free to ask.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@214840332943097856> kapa.ai is still learning and improving, please let us how it did by reacting below