Allow to hide/show inputs when a boolean is toggled
See original GitHub issueLet’s say I have this form:
[ ] Enable SMS? (Boolean)
[ ] Phone Number Required (Boolean)
But I only want to present the Phone Number Required
when the Enable SMS
is true because otherwise, the input doesn’t make sense.
My first thought at schema level would be something like:
"enable_sms": {
"type": "boolean"
},
"require_phone_number": {
"type": "boolean",
"x-render-only-if": "enable_sms"
}
Or something in that sense, the property would specify the one that needs to be “true” to render it.
I’m simplifying here with two inputs but our case includes half a dozen fields that could be hidden.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Hide, show input using toggle jquery boolean - Stack Overflow
I get input from dropdown list and depending on what user chose I want to show/hide different inputs. I have tried using toggle...
Read more >Hide/Show properties dynamically in inspector. - Unity Answers
This creates a toggle that displays similarly to how the Inspector shows a bool field by default. Next I will create a group...
Read more >.toggle() | jQuery API Documentation
A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7,...
Read more >How to Show Hide or Toggle Elements in Angular
I am sharing a simple example here in this post showing how to toggle or show and hide elements in Angular. Let us...
Read more >Collapse - Bootstrap
Collapse. Toggle the visibility of content across your project with a few classes and our JavaScript plugins. Example. Click the buttons below to ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just published the conditional subschema functionality, please have a look here.
I marked it as beta as I still need to think about it and maybe reconsider the implementation. But for simple use-cases like a boolean switch it is safe to use it.
Oh, I see! I didn’t check that the if/then/else was in the JSON spec, in that case, makes more sense to follow it. Thanks! ❤️