# 在构建插件时 settings.yml 中的复杂列表

**URL:** https://meta.discourse.org/t/complex-lists-in-settings-yml-when-building-a-plugin/228992
**Category:** Development
**Created:** [2022年六月4日 05:05 UTC](https://meta.discourse.org/t/complex-lists-in-settings-yml-when-building-a-plugin/228992 "2022-06-04T05:05:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [2022年六月4日 05:05 UTC](https://meta.discourse.org/t/complex-lists-in-settings-yml-when-building-a-plugin/228992/1 "2022-06-04T05:05:13Z")

</div>

我正在构建一个需要自定义列表输入的插件。理想情况下，我希望用户能够在此列表中输入任意数量的元素。我了解到，在构建 settings.yml 时，有一个 `type: list` 选项，它允许输入任意数量的字符串。

然而，我想创建的“列表”比字符串复杂。每个元素包含三个文本字段和一个图像。我目前的解决方案是在 settings.yml 中硬编码 10 个这样的元素，但这需要我定义 40 个自定义变量。

有没有更好的方法来做到这一点？

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [2022年六月4日 06:55 UTC](https://meta.discourse.org/t/complex-lists-in-settings-yml-when-building-a-plugin/228992/2 "2022-06-04T06:55:38Z")

</div>

对于复杂的 UI，您可以使用 `add_admin_route` API，例如在 [Data Explorer](https://meta.discourse.org/t/32566?silent=true) 插件中使用它，这样您就可以完全控制您想要提供的设置的 UI。

它为您提供了一个专用的 ember 路由，您可以自行设计以完全构建 UI。

在 [Data Explorer](https://meta.discourse.org/t/32566?silent=true) 的情况下，URL 是 `yoursite.com/admin/plugins/explorer`。
