Unable to use 'condition'
See original GitHub issueI am using angular2-json-schema-form and trying to make use of the ‘condition’ functionality. In the playground examples for ASF there is the ‘Hack: Conditional Required’ example:
{
"schema": {
"type": "object",
"properties": {
"switch": {
"title": "Spam me, please",
"type": "boolean"
},
"email": {
"title": "Email",
"type": "string",
"pattern": "^\\S+@\\S+$",
"description": "Email will be used for evil."
}
},
"required": [
"switch"
]
},
"form": [
{
"type": "help",
"helpvalue": "<p>Schema Form does not support oneOf (yet), but you can do a workaround and simulate certain scenarios with 'condition' and 'required' (and/or 'readonly') in the form.</p>"
},
"switch",
{
"key": "email",
"condition": "model.switch",
"required": true
},
{
"key": "email",
"condition": "!model.switch"
},
{
"type": "submit",
"style": "btn-info",
"title": "OK"
}
]
}
I have found that both fields are displayed, and the value of ‘condition’ appears to have no effect?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Unable to use condition in requirements.yaml #2111 - GitHub
yaml , I am unable to successfully disable a chart based on a known false boolean value. Replication steps: Download a chart with...
Read more >Cannot create Condition for Flow - Power Platform Community
Solved: I'm creating a flow, but it will not let me add a value to the Condition to establish a relationship. The last...
Read more >Unable to use conditional(when statement and with_file) for ...
If I am using the same condition for task, then it is working fine. debug: msg: "I am running..." when: "'myrole_1' in item"...
Read more >Mental Health and the FMLA | U.S. Department of Labor
Assuming that you work for a covered employer and are eligible for FMLA leave, you may take leave if you are unable to...
Read more >Congestive Heart Failure: Prevention, Treatment and Research
The best way to avoid congestive heart failure is to avoid the conditions that ... If you're unable to take an exercise test,...
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 FreeTop 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
Top GitHub Comments
I actually wanted to show the second item only when the user clicks on No. At the same time I want the value of the No to be false. I was trying with negation, It did working. I used the above example and was able to fix it. Thank you @pdinesh80 !!
Issue:
Solution:
@dschnelldavis Condition works fine as from the example, have a question Can i use condition on string fields instead of boolean and check for expression? for example
{ “schema”: { “type”: “object”, “properties”: { “text”: { “title”: “Spam me, please”, “type”: “string” }, “email”: { “title”: “Email”, “type”: “string”, “pattern”: “^\S+@\S+$”, “description”: “Email will be used for evil.” } }, “required”: [ “switch” ] }, “form”: [ { “type”: “help”, “helpvalue”: “
Schema Form does not support oneOf (yet), but you can do a workaround and simulate certain scenarios with ‘condition’ and ‘required’ (and/or ‘readonly’) in the form.
” }, “switch”, { “key”: “email”, “condition”: “model.text==‘hello’”, “required”: true }, { “key”: “email”, “condition”: “model.text!=‘hello’”, }, { “type”: “submit”, “style”: “btn-info”, “title”: “OK” } ] }UPDATE: From this link https://github.com/dschnelldavis/angular2-json-schema-form/issues/146, found a work around
so we can have condition like this