Skip to content

Commit

Permalink
docs: add dynamic list doc (#373)
Browse files Browse the repository at this point in the history
增加 formkit list 的文档。

/kind documentation

```release-note
None
```
  • Loading branch information
LIlGG committed Jun 26, 2024
1 parent 05c4dc2 commit 976fcd9
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions docs/developer-guide/form-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,55 @@ spec:

除了 FormKit 官方提供的常用输入组件之外,Halo 还额外提供了一些输入组件,这些输入组件可以在 Form Schema 中使用。

### list

#### 描述

列表类型的输入组件,支持动态添加、删除数据项。

#### 参数

- `item-type`:数据项的数据类型,用于初始化数据。可选参数 `string`, `number`, `boolean`, `object`,默认为 `string`
- `min`:数组最小要求数量,默认为 `0`
- `max`:数组最大容量,默认为 `Infinity`,即无限制
- `addButton`:是否显示添加按钮
- `addLabel`:添加按钮的文本
- `upControl`:是否显示上移按钮
- `downControl`:是否显示下移按钮
- `insertControl`:是否显示插入按钮
- `removeControl`:是否显示移除按钮

#### 示例

```yaml
- $formkit: list
name: socials
label: 社交账号
addLabel: 添加账号
min: 1
max: 5
itemType: string
children:
- $formkit: text
index: "$index"
validation: required
```

:::tip
`list` 组件有且只有一个子节点,并且必须为子节点传递 `index` 属性。若想提供多个字段,则建议使用 `group` 组件包裹,并将 itemType 改为 object。
:::

最终保存表单之后得到的值为以下形式:

```json
{
"socials": [
"GitHub",
"Twitter"
]
}
```

### verificationForm

#### 描述
Expand Down

0 comments on commit 976fcd9

Please sign in to comment.