Skip to content

Commit 9c1398b

Browse files
committed
Added docs for multi field conditions
1 parent cc32fa5 commit 9c1398b

File tree

1 file changed

+48
-1
lines changed
  • packages/react-renderer-demo/src/app/pages/renderer

1 file changed

+48
-1
lines changed

packages/react-renderer-demo/src/app/pages/renderer/condition.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,54 @@ You can show a field only if it meets a condition:
3232
}
3333
```
3434

35-
`when` - is name of field where the value is stored, **always required!**
35+
`when` - is name of field where the value is stored, **always required!**. It can be either string `'field-name'` or array of strings `['field-1', 'field-2']`.
36+
37+
#### OR condition. At least one condition must be met
38+
39+
If either of of fields with name `a` and `b` will have value `x` condition is met.
40+
41+
```jsx
42+
{
43+
fields: [{
44+
name: 'Or condition',
45+
component: 'text-field',
46+
condition: {
47+
when: ['a', 'b'],
48+
is: 'x'
49+
}
50+
}]
51+
}
52+
```
53+
54+
#### AND condition. All conditions must be met
55+
56+
Field `controlled-field-1` must have value `Bar` and field `controlled-field-2` must include `FooBar` somewhere in its value to display field `BarFoo`.
57+
58+
```jsx
59+
{
60+
fields: [
61+
{
62+
name: 'controlled-field-1',
63+
component: 'text-field',
64+
},
65+
{
66+
name: 'controlled-field-2',
67+
component: 'text-field',
68+
} {
69+
name: 'BarFoo',
70+
label: 'Foo is Bar!',
71+
component: 'text-field',
72+
condition: [{
73+
when: 'controlled-field-1',
74+
is: 'Bar',
75+
}, {
76+
when: 'controlled-field-2',
77+
pattern: /FooBar/
78+
}],
79+
},
80+
]
81+
}
82+
```
3683

3784
## Conditions
3885

0 commit comments

Comments
 (0)