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