json-editor icon indicating copy to clipboard operation
json-editor copied to clipboard

Is it possible to show a part of the form only if a checkbox is checked?

Open andreimoment opened this issue 9 years ago • 6 comments

If I have something like this:

{
  "title": "Person",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "First and Last name",
      "minLength": 4,
      "default": "Jeremy Dorn"
    },
    "has_pets": {
      "type": "boolean",
      "format": "checkbox",
      "title": "Has Pets?"
    },

    "pets": {
      "type": "array",
      "format": "table",
      "title": "Pets",
      "uniqueItems": true,
      "items": {
        "type": "object",
        "title": "Pet",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "cat",
              "dog",
              "bird",
              "reptile",
              "other"
            ],
            "default": "dog"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "default": [
        {
          "type": "dog",
          "name": "Walter"
        }
      ]
    }
  }
}

How can I make the pets object appear ONLY if has_pets is true? Ideally, the JSON for pets would also be exported only if the condition is true.

andreimoment avatar Jul 17 '15 17:07 andreimoment

Also curious about this, as it seems to be the only missing feature. This is possible in jsonform.

mjau-mjau avatar Aug 14 '15 17:08 mjau-mjau

+1

nicolas-despres avatar Sep 30 '15 05:09 nicolas-despres

+1

UinJack avatar Sep 30 '15 07:09 UinJack

+1

HaNdTriX avatar Oct 19 '15 16:10 HaNdTriX

+1

whtiehack avatar Oct 30 '15 04:10 whtiehack

+1 Is there any solution for this?

KJlmfe avatar Nov 26 '17 11:11 KJlmfe