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

Setting watch for field in array

Open devnull69 opened this issue 8 years ago • 0 comments

If I want to show an option of a select only if another field has a certain value, I can do this (using the Swig template engine):

"outerobject": {
   ...
   "properties": {
      "anotherfield": {
         ...
      },
      "currentfield": {
         ...
         "watch": {
            "watcher": "outerobject.anotherfield"
         },
         "enumSource": [{
            "source" : [{
               ...
               "showwhen": ["option1", "option2"]
            }],
            "filter": "{% if item.watcher.indexOf(watched.showwhen) >= 0 %}1{% endif %}"
         }]
      }
   }
}

But as soon as I want to watch a field which is nested inside an array, I have a problem addressing the "anotherfield". Is there a way to address a field which is nested inside an array? I need a way to address the "current element" of an array, so that I can use this reference in a watch for another field (in the same array).

devnull69 avatar Nov 13 '17 08:11 devnull69