@@ -21,7 +21,9 @@ import { z } from 'zod';
2121``` ts
2222const formSchema = z .object ({
2323 username: z .string ().min (3 , ' Username must be at least 3 characters' ),
24- email: z .string ().email (' Please enter a valid email address' ),
24+ email: z
25+ .email (' Please enter a valid email address' )
26+ .describe (" We'll use this email to contact you. (from zod schema)" ),
2527 user_type: z .enum ([' admin' , ' editor' , ' viewer' ]),
2628 accept_terms: z .boolean ().refine (val => val , {
2729 message: ' You must accept the terms and conditions' ,
@@ -37,55 +39,50 @@ const formSchema = z.object({
3739 id: ' username' ,
3840 component : props => (
3941 <AutoFormInput
42+ { ... props }
4043 description = " This is the username for your application. It should be unique and not shared with anyone."
4144 label = " Username"
42- { ... props }
4345 />
4446 ),
4547 },
4648 {
4749 id: ' email' ,
4850 component : props => (
49- <AutoFormInput
50- description = " We'll use this email to contact you."
51- label = " Email Address"
52- type = " email"
53- { ... props }
54- />
51+ <AutoFormInput { ... props } label = " Email Address" type = " email" />
5552 ),
5653 },
5754 {
5855 id: ' user_type' ,
5956 component : props => (
6057 <AutoFormSelect
58+ { ... props }
6159 description = " Select the type of user."
6260 label = " User Type"
6361 labels = { [
6462 { value: ' admin' , label: ' Admin' },
6563 { value: ' editor' , label: ' Editor' },
6664 { value: ' viewer' , label: ' Viewer' },
6765 ]}
68- { ... props }
6966 />
7067 ),
7168 },
7269 {
7370 id: ' accept_terms' ,
7471 component : props => (
7572 <AutoFormCheckbox
76- label = " I accept the terms and conditions"
7773 { ... props }
74+ label = " I accept the terms and conditions"
7875 />
7976 ),
8077 },
8178 {
8279 id: ' description' ,
8380 component : props => (
8481 <AutoFormTextarea
82+ { ... props }
8583 description = " Write a short description of your application."
8684 label = " Description"
8785 placeholder = " My application is..."
88- { ... props }
8986 />
9087 ),
9188 },
@@ -127,7 +124,7 @@ Auto Form supports all Zod validators:
127124``` ts
128125const formSchema = z .object ({
129126 username: z .string ().min (3 ).max (20 ),
130- email: z .string (). email (),
127+ email: z .email (),
131128 age: z .number ().min (18 ).max (120 ),
132129 password: z
133130 .string ()
@@ -138,6 +135,12 @@ const formSchema = z.object({
138135});
139136```
140137
138+ ## Custom Fields
139+
140+ <Callout type = " warn" title = " This documentation is under construction! 🚧" >
141+ We're working hard to bring you the best documentation experience.
142+ </Callout >
143+
141144## Form Submission
142145
143146To activate submit button and handle form submission with the ` onSubmit ` callback:
@@ -149,9 +152,9 @@ To activate submit button and handle form submission with the `onSubmit` callbac
149152 id: ' username' ,
150153 component : props => (
151154 <AutoFormInput
155+ { ... props }
152156 description = " This is the username for your application."
153157 label = " Username"
154- { ... props }
155158 />
156159 ),
157160 },
0 commit comments