antd useForm hook does not work #3961
-
f12 finds no request bound useOne hooks,No content in queryResult export const UserEdit: React.FC<IResourceComponentsProps> = ({...props}) => {
const { id,setId,form, formProps, saveButtonProps, onFinish,queryResult } = useForm({
action: "edit",
dataProviderName: "usercenter",
resource: `user`,
// id:props.params.id
});
return (
<Edit
saveButtonProps={saveButtonProps}
resource={`user`}
dataProviderName={"usercenter"}
recordItemId={id}
>
<Form form={form} {...formProps} layout="vertical" >
<Form.Item rules={[
{
required: true,
},
]}
label="nickname" name="nickname">
<Input/>
</Form.Item>
<Form.Item label="username" name="username">
<Input disabled/>
</Form.Item>
<Form.Item label="mobile" name="mobile">
<Input disabled/>
</Form.Item>
</Form>
</Edit>
);
}; |
Beta Was this translation helpful? Give feedback.
Answered by
salihozdemir
Mar 24, 2023
Replies: 1 comment 4 replies
-
If you use You can define the const formResult = useForm({
resource: "users",
id: "123456",
}); You can find more information about the Also, you can use the const formResult = useForm({
resource: "users",
});
formResult.setId("123456"); You can find more information about the |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
An0nymous0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use
useForm
with "edit" or "clone" mode, theid
is required. By default,useForm
infers theid
from the URL. If the URL doesn't contain theid
params, you must provide it manually.You can define the
id
in theuseForm
options:You can find more information about the
id
: https://refine.dev/docs/api-reference/antd/hooks/form/useForm/#idAlso, you can use the
setId
method to set theid
after the form is mounted:You can find more information about the
setId
: https://refine.dev/docs/api-reference/antd/hooks/form/useForm/#setid