How to delete input field name with value before submitted form
my-json-data like this "
"groupdetail": [
{
"term_1": 11,
"term_2": 5555,
"term_3": 4444,
"term_4": 10,
"term_5": 10,
"term_6": 7777,
"term_7": 55,
"term_8": 44,
"term_9": 33,
"id": 1
},
"
When "handleRemove" occurs, the object with the last data, "term_9": 33, deleted is passed to onSubmit. However, in my-json-data, "term_9": 33 remains intact. How can I delete this?
2 Replies
Hi @florent_26629. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in the extracts, it seems that you are trying to modify the form data before it is submitted. In refine, you can use the
useForm
hook to achieve this. However, the extracts do not provide a direct solution for deleting a field from the form data before submission.
The useForm
hook in refine allows you to modify the form data before it is submitted to the backend. This is done by defining a custom submit handler function that modifies the form data and then calls the onFinish
function provided by the useForm
hook.
Here is a general example of how you can use the useForm
hook to modify form data:
In this example, the onFinishHandler
function combines the name
and surname
fields into a fullName
field before submitting the form data.
However, to delete a field from the form data, you would need to modify the onFinishHandler
function to remove the field from the data
object before calling onFinish
.
Unfortunately, the provided extracts do not contain a specific example of how to delete a field from the form data before submission. For more detailed information, you may want to refer to the refine documentation (https://refine.dev/docs/guides-concepts/forms/#modifying-data-before-submission).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1184365192482652173> kapa.ai is still learning and improving, please let us know how it did by reacting below