# Rules: Show Control based upon value existing in array

**URL:** <https://jsonforms.discourse.group/t/rules-show-control-based-upon-value-existing-in-array/2244>\
**Category:** General\
**Created:** [July 24, 2024, 11:31am UTC](https://jsonforms.discourse.group/t/rules-show-control-based-upon-value-existing-in-array/2244 "2024-07-24T11:31:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robg](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@robg](https://jsonforms.discourse.group/u/robg)\
**Post date:** [July 24, 2024, 11:31am UTC](https://jsonforms.discourse.group/t/rules-show-control-based-upon-value-existing-in-array/2244/1 "2024-07-24T11:31:23Z")

</div>

The following cut down example allows a select if set to Other to show the Other textfield:

**schema.json**

```auto
"question_set": {
  "type": "object",
  "title": "Questions",
  "properties": {
    "question": {
      "type": ["string", "null"],
      "title": "Question",
      "enum": ["Option 1", "Option 2", "Other"]
    },
    "question_other": {
      "type": ["string", "null"],
      "title": "If other, give detail"
    }
}

```

**uischema.json**

```auto
{
  "type": "Group",
  "label": "Specs",
  "elements": [
    {
      "type": "Control",
      "scope": "#/properties/question_set/properties/question"
    },
    {
      "type": "Control",
      "scope": "#/properties/question_set/properties/question_other",
      "rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#/properties/question_set/properties/question",
          "schema": { "const": "Other" }
        }
      }
    }

```

I’m having issues replicating this case when the source question is a multiselect. Regardless of ‘Other’ being selected it doesn’t appear to work:

**schema.json**

```auto
"question_set": {
  "type": "object",
  "title": "Questions",
  "properties": {
    "question": {
      "type": ["array", "null"],
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "Option 1",
          "Option 2",
          "Other"
        ]
      },
      "title": "question"
    },
    "question_other": {
      "type": ["string", "null"],
      "title": "If other, give detail"
    }
  },

```

**uischema.json**

```auto
{
  "type": "Group",
  "label": "Questions",
  "elements": [
    {
      "type": "Control",
      "scope": "#/properties/question_set/properties/question"
    },
    {
      "type": "Control",
      "scope": "#/properties/question_set/properties/question_other",
      "rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#/properties/question_set/properties/question",
          "schema": { "enum": ["Other"] }
        }
      }
    }
  ]
},

```

There doesn’t appear to be an example of conditional display based upon a multi-select.

Any guidance greatly appreciated.

Rob.

---

<div class="post-metadata">

**Author:** ![robg](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@robg](https://jsonforms.discourse.group/u/robg)\
**Post date:** [July 24, 2024, 11:38am UTC](https://jsonforms.discourse.group/t/rules-show-control-based-upon-value-existing-in-array/2244/2 "2024-07-24T11:38:01Z")

</div>

Resolved: required contains instead… I’m sure I tried that several hours ago!

```auto
{
  "type": "Group",
  "label": "Questions",
  "elements": [
    {
      "type": "Control",
      "scope": "#/properties/question_set/properties/question"
    },
    {
      "type": "Control",
      "scope": "#/properties/question_set/properties/question_other",
      "rule": {
        "effect": "SHOW",
        "condition": {
          "scope": "#/properties/question_set/properties/question",
          "schema": { "contains": { "const": "Other" } }
        }
      }
    }
  ]
},

```
