Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

array.svelte

20 lines475 Bytes

1<svelte:options runes />
2​
3<script lang="ts">
4 import { createForm } from '../src/index.js'
5​
6 const form = createForm(() => ({
7 defaultValues: {
8 test: ['a'] as string[],
9 },
10 }))
11</script>
12​
13<form.Field name="test" mode="array">
14 {#snippet children(field)}
15 <div data-testid="val">{JSON.stringify(field.state.value)}</div>
16 <button data-testid="push" type="button" onclick={() => field.pushValue('b')}>
17 push
18 </button>
19 {/snippet}
20</form.Field>