3
3
import { schemasafe } from ' $lib/adapters/schemasafe.js' ;
4
4
import { loginJSONSchema } from ' ./schemas.js' ;
5
5
6
- const { form, errors, message, enhance } = superForm (defaults (schemasafe (loginJSONSchema )), {
7
- SPA: true ,
8
- validators: schemasafe (loginJSONSchema ),
9
- onUpdate({ form }) {
10
- if (form .valid ) {
11
- // TODO: Call an external API with form.data, await the result and update form
12
- }
13
- }
14
- });
6
+ const { form, errors, message, constraints , enhance } = superForm (defaults (schemasafe (loginJSONSchema )), {
7
+ SPA: true ,
8
+ validators: schemasafe (loginJSONSchema ),
9
+ onUpdate({ form }) {
10
+ if (form .valid ) {
11
+ // TODO: Call an external API with form.data, await the result and update form
12
+ }
13
+ }
14
+ });
15
15
</script >
16
16
17
17
<h1 >Edit user</h1 >
18
18
19
19
{#if $message }<h3 >{$message }</h3 >{/if }
20
20
21
21
<form method =" POST" use:enhance >
22
- <label >
23
- Name<br />
24
- <input aria-invalid ={$errors .name ? ' true' : undefined } bind:value ={$form .name } />
25
- </label >
26
- {#if $errors .name }<span class ="invalid" >{$errors .name }</span >{/if }
22
+ <label >
23
+ Name<br />
24
+ <input
25
+ aria-invalid ={$errors .name ? ' true' : undefined }
26
+ bind:value ={$form .name }
27
+ {...$constraints .name } />
28
+ </label >
29
+ {#if $errors .name }<span class ="invalid" >{$errors .name }</span >{/if }
27
30
28
- <label >
29
- E-mail<br />
30
- <input
31
- type =" email"
32
- aria-invalid ={$errors .email ? ' true' : undefined }
33
- bind:value ={$form .email }
34
- />
35
- </label >
36
- {#if $errors .email }<span class ="invalid" >{$errors .email }</span >{/if }
37
- <br />
38
- <button >Submit</button >
39
- </form >
31
+ <label >
32
+ E-mail<br />
33
+ <input
34
+ type =" email"
35
+ aria-invalid ={$errors .email ? ' true' : undefined }
36
+ bind:value ={$form .email }
37
+ {...$ constraints . email } />
38
+ </label >
39
+ {#if $errors .email }<span class ="invalid" >{$errors .email }</span >{/if }
40
+ <br />
41
+ <button >Submit</button >
42
+ </form >
0 commit comments