how to use rules in Json forms with object from array as condition?

645 Views Asked by At

i am using json-forms with react and i want to introduce condition where category is hidden and it will show depending on object inside an array.

here is pseudo schema

       var schema = {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "alive": {
          "type": "array",
          "items": {
                "type": "boolean"
            }
        },
        "kindOfDead": {
          "type": "string",
          "enum": [
            "Zombie",
            "Vampire",
            "Ghoul"
          ]
        }
      }
    }



    var uiSchema = {
      "type": "Categorization",
      "elements": [
        {
          "type": "Category",
          "label": "Private",
          "elements": [
            {
          "type": "Control",
          "label": "Name",
          "scope": "#/properties/name"
            }
          ]
        },
        {
          "type": "Category",
          "label": "public",
"rule": {
            "effect": "DISABLE",
            "condition": {
              "scope": "#/properties/alive",
              "schema": {
                "kindOfDead": true
              }
            }
          },
          "elements": [
            {
          "type": "Control",
          "label": "Kind of dead",
          "scope": "#/properties/kindOfDead"
        }
          ]
        }
      ]
    }

    var data = {
      "name": "John Doe",
      "alive": [
          isZombie:true,
      ],
        "kindOfDead": "Zombie"
    }

so in this case depends on the isZombie value the tab should be disabled or enabled. and the value of the isZombie is provided from pre sent data nor from user

0

There are 0 best solutions below