Skip to content

Field value (return of useForm) disappear when input value change #668

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

You must be logged in to vote

Conform does not maintain any of the value and always uses the DOM (FormData) as the source of truth. If you wanna persist the data, you will need to render a hidden input for both id and name as well, like this:

export function Example() {
  // ...

  return (
    <>
      <form {...getFormProps(form)}>
        {students.map((student) => {
          const studentField = student.getFieldset();
          const { key: studendKey, ...emailFieldProps } = getInputProps(studentField.email, {
            type: 'text',
          });
          return (
            <div key={student.id}>
              <input {...getInputProps(studentField.id, { type: 'hidden' })} />
              id:{studentField.id.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@WMinsane
Comment options

@brunobely
Comment options

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