Skip to content

useControl strange behaviour #474

Answered by edmundhung
stimw asked this question in Q&A
Discussion options

You must be logged in to vote

This is because you are leaving it to mantine to decide how the input is rendered when you provide a name prop to it. If you inspect the element, you will find this html:

<input type="hidden" name="control" value="2026-02-12T23:00:00.000Z">

If you wanna have full control over the value on the input, it would be better to create your own hidden input like this:

<input
  type="hidden"
  ref={control.register}
  name={fields.control.name}
  defaultValue={control.value}
/>
<DatePickerInput
  label="useControl"
  placeholder="Pick date"
  valueFormat="DD/MM/YYYY"
  name={fields.control.name}
  value={control.value ? stringToDate(control.value) : null}
  onChange={(value) => control.change(value

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stimw
Comment options

Answer selected by stimw
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
Converted from issue

This discussion was converted from issue #472 on February 21, 2024 17:00.