useform attach initialfilter strapi v4

} = useForm({

refineCoreProps: {
mutationMode: "pessimistic",
//config: {
//filters: [{ field: "variable][id]", operator: "eq", value: selectedVariable }],
// },
}
});
} = useForm({

refineCoreProps: {
mutationMode: "pessimistic",
//config: {
//filters: [{ field: "variable][id]", operator: "eq", value: selectedVariable }],
// },
}
});
how can i attach filter in useform for edit? it works in useList.
8 Replies
kapa.ai
kapa.ai2y ago
Hey @.yoda.! I'm the kapa.ai support bot. I've searched through the docs to try to answer your question. :wave:
kapa.ai
kapa.ai2y ago
---------------------- In edit mode, you can pass queryOptions (https://tanstack.com/query/v4/docs/react/reference/useQuery) options to useForm by passing queryOptions property. For example, if you want to attach a filter to useForm in edit mode, you can do the following:
useForm({
queryOptions: {
retry: 3,
filters: [{ field: "variable][id]", operator: "eq", value: selectedVariable }],
},
});
useForm({
queryOptions: {
retry: 3,
filters: [{ field: "variable][id]", operator: "eq", value: selectedVariable }],
},
});
For more information, please refer to the refine documentation (https://refine.dev/docs/api-reference/core/hooks/useForm). ----------------------
kapa.ai
kapa.ai2y ago
Did kapa.ai help answer your question?
<@271294719559073792> kapa.ai is still learning and improving, please let us how it did by reacting with a :thumbsup: or :thumbsdown:
fascinating-indigo
fascinating-indigo2y ago
Bots answer did not work
ambitious-aqua
ambitious-aqua2y ago
Hello @.yoda. since edit is related to single resource, I'm not sure if you should have filter on useForm.
fascinating-indigo
fascinating-indigo2y ago
@batuhanw thanks for the quick answer. since i am working with strapi in the backend i try to send some extra information to the backend to check some logic. is there a way i can attach this extra information to the useForm?
ambitious-aqua
ambitious-aqua2y ago
Hello @.yoda., you can use metaData field to pass extra fields to your data provider: https://refine.dev/docs/packages/documentation/react-hook-form/useForm/#metadata
useForm | refine
The @pankod/refine-react-hook-form adapter allows you to integrate the React Hook Form library with refine, enabling you to manage your forms in a headless manner. This adapter supports all of the features of both React Hook Form and refine's useForm hook, and you can use any of the React Hook Form examples as-is by copying and pasting them into...
fascinating-indigo
fascinating-indigo2y ago
Thanks a lot 👍