在数组中使用数组

Using an array inside array

我正在尝试生成一个包含多辆车的表格,每辆车应该有多个人。

我试图通过在另一个数组中使用一个数组来做到这一点。但由于一些不明原因,它不起作用。

这就是我想要的: http://i.imgur.com/ZB2kCa1.png

这是我所拥有的(到目前为止):

表格:

[
  {
    "key": "vehicles",
    "items": [
      "['vehicles'][]['plate-number']",
      "['vehicles'][]['color']",
      {
        "key": "people",
        "items": [
            "['vehicles'][]['people'][]['name']"
        ]
      }
    ]
  }
]

架构:

{
  "type": "object",
  "properties": {
    "vehicles": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "plate-number": {
            "title": "Plate number",
            "type": "string"
          },
          "color": {
            "title": "Color",
            "type": "string"
          },
          "people": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string",
                  "enum": ["dr","jr","sir","mrs","mr","NaN","dj"]
                },
                "name": {
                  "title": "Name",
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}

编辑: stefankmitph 的回答解决了我的问题。谢谢!

但奇怪的事情发生了:在 vehicles 的同一级别添加了一个新对象 person。另外,当我填写一个人的信息然后删除这个人时,模型没有更新。

您提供的架构未添加 属性 'gender'(如您的图片所示 link)。所以我用 'title' 而不是 'gender':

[
  {
    "key": "vehicles",
    "items": [
      "vehicles[].plate-number",
      "vehicles[].color", {
          "key": "people",
          "type": "array",
          "title": "People",
          "items": [
              "vehicles[].people[].name",
              "vehicles[].people[].title"
              ]
      }
    ]
  }
]

希望这就是您要找的! 注意:使用 Schema Form Example Page

测试