jdorn / json-editor

JSON Schema Based Editor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting watch for field in array

devnull69 opened this issue · 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).