Skip to content

antd useForm hook does not work #3961

Closed Answered by salihozdemir
An0nymous0 asked this question in Q&A
Discussion options

You must be logged in to vote

If you use useForm with "edit" or "clone" mode, the id is required. By default, useForm infers the id from the URL. If the URL doesn't contain the id params, you must provide it manually.

You can define the id in the useForm options:

const formResult = useForm({
    resource: "users",
    id: "123456",
});

You can find more information about the id: https://refine.dev/docs/api-reference/antd/hooks/form/useForm/#id

Also, you can use the setId method to set the id after the form is mounted:

const formResult = useForm({
    resource: "users",
});

formResult.setId("123456");

You can find more information about the setId: https://refine.dev/docs/api-reference/antd/hooks/form/useForm/#setid

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@An0nymous0
Comment options

@salihozdemir
Comment options

@salihozdemir
Comment options

@An0nymous0
Comment options

Answer selected by An0nymous0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants