RSJF "And" dependencies

29 Views Asked by At

I would like using react-json-form-schema to do a simple "and" dependency, ie show a field if 2 conditions are true:

{
    "type": "object",
    "title": "test",
    "properties": {
        "videoGames": {
            "type": "string",
            "title": "Do you like video games?",
            "oneOf": [
                {
                    "title": "No",
                    "const": "No"
                },
                {
                    "title": "Yes",
                    "const": "Yes"
                }
            ],
            "default": "No"
        },
        "movies": {
          "type": "string",
          "title": "Do you like movies?",
          "oneOf": [
                {
                    "title": "No",
                    "const": "No"
                },
                {
                    "title": "Yes",
                    "const": "Yes"
                }
            ],
            "default": "No"
        }
    }
}

I would like to display a new field if I answered "Yes" to both. Is it possible to do?

Thank you!

I have tried to add "dependencies

{
    "dependencies": {
        "allOf": {
            "properties": {
                "videoGames": {
                    "const": "Yes"
                },
                "movies": {
                    "const": "Yes"
                },
                "both": {
                    "type": "string",
                    "title": "Waw, you like video games AND movies!"
                }
            }
        }
    }
}

0

There are 0 best solutions below