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

AppForm.svelte

26 lines618 Bytes

1<svelte:options runes />
2​
3<script lang="ts">
4 import { appForm } from './app-form.svelte.js'
5​
6 const form = appForm.useAppForm(() => ({
7 defaultValues: { guest: { name: 'Tony' } },
8 }))
9 let label = $state('Name')
10</script>
11​
12<form.AppForm>
13 <form.FormGroup name="guest">
14 {#snippet children(group)}
15 <group.Field name="name">
16 {#snippet children(field)}
17 <field.TextField {label} />
18 {/snippet}
19 </group.Field>
20 {/snippet}
21 </form.FormGroup>
22 <form.Summary />
23 <button type="button" onclick={() => (label = 'Guest name')}>
24 Update label
25 </button>
26</form.AppForm>