Skip to content

group + rule is not work #111

@njuptlzf

Description

@njuptlzf

jsonform

value.json

{
  "size": 1,
  "container1": {
    "name": "Initial Name for Container 1",
    "image": "https://example.com/image.png"
  },
  "container2": {
    "name": "Initial Name for Container 2",
    "url": "https://example.com"
  }
}

schema.json

{
  "type": "object",
  "properties": {
    "size": {
      "type": "integer",
      "title": "Size",
      "enum": [1, 2],
      "default": 1
    },
    "container1": {
      "type": "object",
      "title": "Container 1",
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "image": {
          "type": "string",
          "title": "Image URL"
        }
      }
    },
    "container2": {
      "type": "object",
      "title": "Container 2",
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "url": {
          "type": "string",
          "title": "URL"
        }
      }
    }
  }
}

ui-schema.json

{
  "type": "VerticalLayout",
  "elements": [
    {
      "type": "Control",
      "scope": "#/properties/size",
      "label": "Size",
      "options": {
        "format": "radio"
      }
    },
    {
      "type": "Group",
      "label": "Container 1",
      "elements": [
        {
          "type": "Control",
          "scope": "#/properties/container1/properties/name",
          "label": "Name"
        },
        {
          "type": "Control",
          "scope": "#/properties/container1/properties/image",
          "label": "Image URL"
        }
      ],
      "rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#/properties/size",
          "schema": {
            "const": 1
          }
        }
      }
    },
    {
      "type": "Group",
      "label": "Container 2",
      "elements": [
        {
          "type": "Control",
          "scope": "#/properties/container2/properties/name",
          "label": "Name"
        },
        {
          "type": "Control",
          "scope": "#/properties/container2/properties/url",
          "label": "URL"
        }
      ],
      "rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#/properties/size",
          "schema": {
            "const": 2
          }
        }
      }
    }
  ]
}

result

Image

other info

If it is a simple string, then it is fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions