Skip to content

Dynamic array of values #573

Answered by edmundhung
iakshay asked this question in Q&A
Apr 5, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

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

Replies: 1 comment 1 reply

Comment options

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

Answer selected by iakshay
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