# Rule in element inside of array

**URL:** <https://jsonforms.discourse.group/t/rule-in-element-inside-of-array/2319>\
**Category:** General\
**Created:** [September 2, 2024, 1:33pm UTC](https://jsonforms.discourse.group/t/rule-in-element-inside-of-array/2319 "2024-09-02T13:33:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pegu](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@pegu](https://jsonforms.discourse.group/u/pegu)\
**Post date:** [September 2, 2024, 1:33pm UTC](https://jsonforms.discourse.group/t/rule-in-element-inside-of-array/2319/1 "2024-09-02T13:33:00Z")

</div>

Hey,

I wonder if adding a rule to element inside of array is only possible through custom renderers or is there a much simple way to make it work with material renderers? I’ve tried such uiSchema with simple rule

```auto
{
    type: 'VerticalLayout',
    elements: [
      {
        type: 'Control',
        scope: '#/properties/simpleTextField',
        label: 'Simple Text Field',
      },
      {
        type: 'Control',
        scope: '#/properties/myArray',
        label: 'My Array',
        options: {
          detail: {
            type: 'VerticalLayout',
            elements: [
              {
                type: 'Control',
                scope: '#/properties/field1',
                label: 'Field 1',
                rule: {
                  effect: 'HIDE',
                  condition: {
                    scope: '#/properties/simpleTextField',
                    schema: {
                      const: '123',
                    },
                  },
                },
              },
              {
                type: 'Control',
                scope: '#/properties/field2',
                label: 'Field 2',
              },
            ],
          },
        },
      },
    ],
  }

```

It works for whole array when I move rule to array element, but not just for a field inside. Am I missing something or only way to do it are custom renderers?

Thanks in advance and have a nice day 😃

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [September 2, 2024, 2:56pm UTC](https://jsonforms.discourse.group/t/rule-in-element-inside-of-array/2319/2 "2024-09-02T14:56:54Z")

</div>

Hi @pegu,

The way the rules are implemented currently, you can’t refer to fields outside of the array. If that is something which you would like to support, then you need to implement a custom renderer which is able to resolve these rules.

Generally I would also be open for contributions to JSON Forms which generalize this rule resolving a bit to allow for more complex use cases than the current ones, like resolving outside the array.
