peterp
March 22, 2019, 6:49am
1
Hi all,
i’m looking for a way to create a dependency between a toggle and other components.
If the toggle is true then other fields should be required: true.
The best solution would be: if the toggle is set to true, the whole area will slide out, is this possible?
thx for help!
We have conditional fields since v3.1. You can set that certain fields are only shown if a toggle value is true.
peterp
March 22, 2019, 8:04am
4
one thing: “when toggle” = true seems not to work with required fields.
I have to fill those fields also when toggle = false, am i right?
That’s one of the things I wanted to check out and haven’t come round to yet. It might well be that it doesn’t work if the fields are required.
Can’t think of a workaround at the moment.
Yes, required fields are always required, displayed or not. So if you hide Fields through conditions they shouldn’t be required.
Then we need conditional attributes:
text:
type: text
required:
when:
toggle: true
when:
toggle: true
Or automatically unset the required attribute when condition is false.
text:
type: text
required:
when:
toggle: true
when:
toggle: true
this code works ?
I’m tryng to show a field only if the toggle is on but the required validation isnt working
In the end it was implemented as
text:
type: text
required: true
when:
toggle: true
If this doesn’t work in current versions, then I guess that would be a bug.
1 Like