How do you integrate @mantine/date components with @mantine/form forms? #6214
-
The documentation for @mantine/date does not include any examples of integrating the components into a larger form. I found that I could connect the form's state to a date component by using <DateTimePicker {...form.getInputProps("example")} /> But resetting the parent form does not reset the date component to its initial state. Given a component with the following JSX: <form>
<DateTimePicker {...form.getInputProps("example")} />
<Button color="red" onClick={form.reset}>Cancel</Button>
</form> Clicking the reset button does not reset the date picker, but it does reset the values of the other inputs in the form (omitted in the snippet for brevity). In both code snippets, interface FormValues {
example: string | null;
}
const form = useForm<FormValues>({
mode: "uncontrolled",
initialValues: {
example: null,
},
}); Is there a way to make |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Uncontrolled form mode requires |
Beta Was this translation helpful? Give feedback.
Uncontrolled form mode requires
key={form.key('example')}
in order to work correctly.