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
import ListOfContents from '../../src/helpers/list-of-contents';
7
+
8
+
<Gridcontaineritem>
9
+
<Griditemxs={12}md={10}>
10
+
11
+
# Initialize On Mount
12
+
13
+
Data Driven Forms provides a way how you can easily initialized a field when the field is mounted (re-mounted).
14
+
15
+
Just pass a `initializeOnMount` prop and set it to `true`.
16
+
17
+
The field will use the `initialValue` set in the schema (<RouterLinkhref="/renderer/component-api#formgroupwrappedcomponents"><Link>initialValue</Link></RouterLink>) or in the renderer (<RouterLinkhref="/renderer/renderer-api#optionalprops"><Link>initialValues</Link></RouterLink>).
18
+
19
+
`initialValue` has higher priority than a value from `initialValues`.
20
+
21
+
## Example
22
+
23
+
24
+
```jsx
25
+
{
26
+
component:componentTypes.TEXT_FIELD,
27
+
name:'name',
28
+
initializeOnMount:true,
29
+
initialValue:'this value will be set'
30
+
}
31
+
```
32
+
33
+
## When to use it?
34
+
35
+
This feature comes handy if you need change a value when an user traverses a form, which shows and hides fields, and the value is not set by the user. Very useful case is used it wizard forms, where you can set different value for the same input according the way the user went in the wizard form by using this option combined with <RouterLinkhref="/renderer/component-api#commonpropsforallformfields"><Link>hideField</Link></RouterLink> prop.
36
+
37
+
<RawComponentsource="initialize-mount" />
38
+
39
+
## Clear the value
40
+
41
+
If you need clear the value after unmounting, you can do it by using <RouterLinkhref="/renderer/unmounting"><Link>clearOnUnmount</Link></RouterLink>.
0 commit comments