json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

Condition for nested array? #962

Closed person2713 closed 6 years ago

person2713 commented 6 years ago

I have some example:

`
{
  "schema": {
  "type": "object",
  "properties": {
    "name": {
        "type": "string"
    },
    "Objects": {
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "object": {
                    "type": "object",
                    "properties": {
                        "objectId": {
                            "type": "string"
                        },
                        "objectName": {
                            "type": "string"
                        },
                        "attributes": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "attributeId": {
                                        "type": "string"
                                    },
                                    "attributeName": {
                                        "type": "string"
                                    },
                                    "value": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
  }
},
  "form": [
      {
        key: 'name'
      },
      {
        key: 'Objects',
        type: 'array',
        items: [
          {
            key: 'Objects[].object',
            items: [
              {
                key: 'Objects[].object.objectId'
              },
              {
                key: 'Objects[].object.objectName',
                condition: 'model.Objects[arrayIndex].object.objectId',
                readonly: 'true'
              },
              {
                key: 'Objects[].object.attributes',
                type: 'array',
                items: [
                  {
                    key: 'Objects[].object.attributes[].attributeId'
                  },
                  {
                    key: 'Objects[].object.attributes[].attributeName',
                    condition: 'model.Objects[arrayIndices[0]].object.attributes[arrayIndices[1]].attributeId',
                    readonly: 'true'
                  },
                  {
                    key: 'Objects[].object.attributes[].value'
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        type: 'section',
        htmlClass: 'row',
        items: [
          {
            type: 'section',
            htmlClass: 'col-md-1',
            items: [
              {
                type: 'submit',
                title: 'Add'
              }
            ]
          }
        ]
      }
    ]
}
`

on https://angular2-json-schema-form.firebaseapp.com/?set=asf&example=asf-array&framework=bootstrap-4&language=en. There are any idea? P. S. I read #742 but it does't work.

Anthropic commented 6 years ago

@person2713 There is no relationship between angular2-json-schema-form and angular-schema-form.