Dynamic array of values #573
-
Hi, is it possible to add an item to an array field. It's not clear to me, how I can add an items to Here is how remix-validated-form does it - https://www.remix-validated-form.io/reference/use-field-array |
Beta Was this translation helpful? Give feedback.
Answered by
edmundhung
Apr 8, 2024
Replies: 1 comment 1 reply
-
You will need to use the insert intent to add an item. There are both a declarative version that works before JS or an imperative version: // Declarative
<button
type="submit"
{...form.insert.getButtonProps({ name: fields.todos.name, defaultValue: '' })
/>
// imperative
<button
type="button"
onClick={() => form.insert({ name: fields.todos.name, defaultValue: '' })}
/> You can also find a working example here: https://stackblitz.com/github/edmundhung/conform/tree/main/examples/remix |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
iakshay
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You will need to use the insert intent to add an item. There are both a declarative version that works before JS or an imperative version:
You can also find a working example here: https://stackblitz.com/github/edmundhung/conform/tree/main/examples/remix