You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,17 +4,21 @@ import DocPage from '@docs/doc-page';
4
4
5
5
# Schema Introduction
6
6
7
+
<br/>
8
+
7
9
## Schema definition
8
10
9
-
A schema is an object consists of fields:
11
+
A schema is an object consists of `fields`:
10
12
11
13
```jsx
12
14
{
13
15
fields: []
14
16
}
15
17
```
16
18
17
-
Other attribues, such as title or description, can be used in [form templates](/components/form-template).
19
+
Other attributes, such as `title` or `description`, can be used in [form templates](/components/form-template).
20
+
21
+
<br/>
18
22
19
23
## Field definition
20
24
@@ -39,20 +43,52 @@ Other attribues, such as title or description, can be used in [form templates](/
39
43
...componentSpecificAttributes
40
44
}
41
45
```
46
+
<br/>
42
47
43
48
### component (required)
44
49
45
50
*string*
46
51
47
-
`component` is a string value representing used component. Available options depends on the component mapper. Data Driven Forms automatically checks if the component is available, if not, it shows an error message. You can use [componentTypes](/schema/constants#componenttypes) to prevent typos. This attribute is not required for fields of these components: `wizard`, `field-array` and `tabs` as these fields include only special components with no implementation.
52
+
The value of `component` is a *string* that represents used component. Available options depend on the [component mapper](/mappers/custom-mapper#Componentmapper).
53
+
54
+
**Data Driven Forms** automatically checks if the component is available; if not, it shows an error message. You can use [componentTypes](/schema/constants#componenttypes) to prevent typos.
55
+
56
+
This attribute is not required for the first level of the `fields` in the following components, as this first level of the `fields` is implemented with special predefined components:
57
+
58
+
`wizard`, `field-array`, `tabs`
59
+
60
+
<br/>
61
+
62
+
Here is an example for `wizard`:
63
+
```jsx
64
+
constschema= {
65
+
fields: [{
66
+
component:'wizard', // here you define the wizard component
67
+
name:'wizard-field',
68
+
...
69
+
// first level of this `fields` are the direct children of wizard - wizard-steps
70
+
fields: [{
71
+
name:'step-1',
72
+
title:'Foo',
73
+
...
74
+
fields: [{
75
+
// these are not children of the wizard step and you require a component attribute again
76
+
component:'text-field',
77
+
name:'bar',
78
+
...
79
+
}]
80
+
}]
81
+
}]
82
+
}
83
+
```
48
84
49
85
---
50
86
51
87
### name (required)
52
88
53
89
*string*
54
90
55
-
`name` represents the variable the form value is stored in. You can use [dot notation](https://final-form.org/docs/final-form/field-names) to create nested objects.
91
+
`name` represents the variable that stores the form value. You can use [dot notation](https://final-form.org/docs/final-form/field-names) to create nested objects.
56
92
57
93
```jsx
58
94
{
@@ -61,7 +97,7 @@ Other attribues, such as title or description, can be used in [form templates](/
61
97
}
62
98
```
63
99
64
-
will be transformed to
100
+
The code above will be automatically transformed to:
65
101
66
102
```jsx
67
103
{
@@ -71,39 +107,50 @@ will be transformed to
71
107
}
72
108
```
73
109
110
+
74
111
---
75
112
76
113
### actions
77
114
78
115
*object*
79
116
80
-
An object that allows to map other properties to globally defined actions. For example, a select has lazy loaded option and with this you can define parameters for the function and keep them in a string format. Read more [here](/mappers/action-mapper).
117
+
The *object* of actions maps other properties to globally defined actions.
118
+
119
+
For example, a `select` has lazy loaded option. With actions, you can define parameters for the function, and keep them in a *string* format.
120
+
121
+
[Read more.](/mappers/action-mapper)
122
+
81
123
82
124
---
83
125
84
126
### clearedValue
85
127
86
128
*any*
87
129
88
-
A value that will be used if the field is cleared. Read more [here](/schema/cleared-value).
130
+
If the field is cleared, clearedValue defines the value that will be used.
131
+
132
+
[Read more.](/schema/cleared-value)
133
+
89
134
90
135
---
91
136
92
137
### clearOnUnmount
93
138
94
139
*bool*
95
140
96
-
When `true`, the value will be cleared after the component is unmounted. Read more [here](/schema/clear-on-unmount)
141
+
When clearOnUnmount is `true`, after the component is unmounted, the value will be cleared.
142
+
143
+
[Read more](/schema/clear-on-unmount).
97
144
98
145
---
99
146
100
147
### condition
101
148
102
149
*object* | *array*
103
150
104
-
`condition` allows to hide/show field when a [condition](/schema/condition-schema) is fulfilled.
151
+
When a [`condition`](/schema/condition-schema) is fulfilled, it can show or hide a component.
105
152
106
-
Example:
153
+
Here is an example:
107
154
108
155
```jsx
109
156
{
@@ -115,21 +162,45 @@ Example:
115
162
}
116
163
```
117
164
118
-
A field with this configuration will be shown only if the first name is Douglas.
165
+
In this example, only if the `first-name` is `Douglas`, the field appears.
166
+
167
+
<br/>
168
+
169
+
The following multiple condition types can be [nested](/schema/condition-nesting):
There are multiple condition types: [and](/schema/and), [or](/schema/or), [not](/schema/not), [sequence](/schema/condition-sequence) that can be [nested](/schema/condition-nesting).
175
+
The following are multiple matchers:
121
176
122
-
And there are multiple matchers: [is](/schema/is), [isEmpty](/schema/is-empty), [isNotEmpty](/schema/is-not-empty), [pattern](/schema/pattern). Some of these matchers can be inverted by using [notMatch](/schema/not-match).
There are also two actions that can be binded to conditions: [set](/schema/condition-set) and [visible](/schema/condition-visible).
125
187
126
188
---
127
189
128
190
### dataType
129
191
130
-
one of strings: *integer | float | number | boolean | string*
192
+
*string*
193
+
194
+
The value of dataType must be one of the following strings:
195
+
196
+
`"integer"`, `"float"`, `"number"`, `"boolean"` or `"string"`.
197
+
198
+
<br/>
199
+
200
+
The value of this component will be converted to the type that dataType indicates.
201
+
202
+
[Read more.](/schema/data-types)
131
203
132
-
Data type sets the type the value will be converted to. Read more [here](/schema/data-types).
133
204
134
205
---
135
206
@@ -139,49 +210,62 @@ Data type sets the type the value will be converted to. Read more [here](/schema
139
210
140
211
You can pass additional [Final Form FieldProps](https://final-form.org/docs/react-final-form/types/FieldProps) via FieldProps object. This prop is made to avoid conflicts between Final Form props and component props.
141
212
213
+
142
214
---
143
215
144
216
### hideField
145
217
146
218
*bool*
147
219
148
-
When `true`, then this will be hidden by CSS. The value will be still registered and submitted.
220
+
When the hideField is `true`, CSS hides this filed. The value will be still registered and submitted.
221
+
149
222
150
223
---
151
224
152
225
### initializeOnMount
153
226
154
227
*bool*
155
228
156
-
When `true`, the value will be re-initialized every time the component is mounted. Read more [here](/schema/initialize-on-mount).
229
+
When initializeOnMount is `true`, every time the component is mounted, the value will be re-initialized.
230
+
231
+
[Read more.](/schema/initialize-on-mount)
232
+
157
233
158
234
---
159
235
160
236
### initialValue
161
237
162
238
*any*
163
239
164
-
Sets an initial value of the field. Read more [here](https://final-form.org/docs/react-final-form/types/FieldProps#initialvalue).
**Only applicable for fields connected to the form state.**
251
+
**resolveProps is only applicable for fields that connected to the form state.**
252
+
253
+
The function of resolveProps can compute field properties from the current state of the field.
254
+
255
+
[Read more.](/schema/resolve-props)
173
256
174
-
A function allowing to compute field properties from the current state of the field. Read more [here](/schema/resolve-props).
175
257
176
258
---
177
259
178
260
### validate
179
261
180
262
*array*
181
263
182
-
`validate` array sets up validation of the field. It is an array of objects/functions:
264
+
`validate` array sets up validation of the field. It is an array of the following objects or functions:
183
265
184
-
**object**
266
+
<br/>
267
+
268
+
**Object**
185
269
186
270
```jsx
187
271
{
@@ -190,19 +274,27 @@ A function allowing to compute field properties from the current state of the fi
190
274
}
191
275
```
192
276
193
-
Type is one of our provided validators: [required](/schema/required-validator), [length](/schema/length-validator), [URL](/schema/url-validator), [pattern](/schema/pattern-validator), [number value](/schema/number-value-validator). You can use [validatorTypes](/schema/constants#validatortypes) to prevent typos.
277
+
Type is one of our provided validators:
278
+
279
+
[`REQUIRED`](/schema/required-validator), [`[MIN|MAX|EXACT]_LENGTH`](/schema/length-validator), [`URL`](/schema/url-validator), [`PATTERN`](/schema/pattern-validator) or [`[MIN|MAX]_NUMBER_VALUE`](/schema/number-value-validator).
194
280
195
-
Or you can implement your own via creating a [validator mapper](/mappers/validator-mapper).
281
+
You can use [validatorTypes](/schema/constants#validatortypes) to prevent typos.
282
+
283
+
You can also implement your own validator by creating a [validator mapper](/mappers/validator-mapper).
284
+
285
+
<br/>
196
286
197
287
**Message**
198
288
199
-
All provided validators let you change the message via [message attribute](/schema/custom-validator-message) or you can set them[globally](/schema/overwriting-default-message).
289
+
All provided validators allows you to change the message via [message attribute](/schema/custom-validator-message); you can also set the message[globally](/schema/overwriting-default-message).
200
290
201
291
By default, each validator provides a default message in English.
202
292
203
-
**function**
293
+
<br/>
294
+
295
+
**Function**
204
296
205
-
You can pass a [custom function](/schema/custom-validator):
297
+
You can pass a [custom function](/schema/custom-validator) as the following example:
206
298
207
299
```jsx
208
300
{
@@ -213,11 +305,12 @@ You can pass a [custom function](/schema/custom-validator):
213
305
214
306
This also supports using [async functions](/schema/async-validator).
215
307
308
+
216
309
---
217
310
218
311
### componentSpecificAttributes
219
312
220
-
Each component defines its required and optional props. Read more [here](/provided-mappers/component-api).
313
+
Each component defines its required and optional props.
221
314
222
315
```jsx
223
316
{
@@ -229,4 +322,6 @@ Each component defines its required and optional props. Read more [here](/provid
0 commit comments