首页 > 解决方案 > 如何创建数据源以从相同形式的数据数组中进行选择?

问题描述

我想在羊驼形式中制作选择字段,它以相同的形式从其他数组中获取数据。

无法从文档中理解它是如何制作的

标签: alpacajs

解决方案


{"schema":{
  "properties":{
     "selectedEventType":{
         "type":"number",
         "title":"Event Type"
      }
  }
}

和...

{"options":{
  "fields":{
      "selectedEventType":{
        "type": "select",
        "dataSource": "/mycontroller/options/event",
        "removeDefaultNone": true,
        "helper": "list of selectable options"
       }
  }
}

在 (/mycontroller/options/event) 的 REST api 中返回如下所示的数据:

{[ {"text":"one","value":1},{"text":"two","value":2},{"text":"three","value":3} ]}

推荐阅读