neoscms

Only show a property in inspector when multiple other properties are set


I want to only show a property in the inspector when multiple other properties are set, like:

'Example.Example:Content.Whatever':
  properties:
    prop1:
      type: boolean
    prop2:
      type: boolean
    prop3:
      type: string
      ui:
        inspector:
          hidden: 'ClientEval:node.properties.prop1 ? false : {ClientEval:node.properties.prop2 ? true : false}'

This example doesn't work, but maybe it explains my intention.

The official neos docs only have an example for 1 condition which works but is not enough.


Solution

  • You made it almost. You have just to use && to combine it in your if statement

    This will hide the element if the other two properties are true:

        test:
          type: boolean
          ui:
            label: 'test dependent hidden'
            inspector:
              group: general
        test2:
          type: boolean
          ui:
            label: 'test2 dependent hidden'
            inspector:
              group: general
        hideMe:
          type: boolean
          ui:
            label: 'hideme dependent hidden'
            inspector:
              group: general
              hidden: 'ClientEval:node.properties.test && node.properties.test2 ? true : false'