Skip to content

Commit

Permalink
docs: add explanation for formkit select fieldSelectorKey property (#409
Browse files Browse the repository at this point in the history
)

#### What this PR does / why we need it:

为 formkit select 组件的远程搜索,增加 `fieldSelectorKey` 字段的使用说明。

see halo-dev/halo#6591

#### Does this PR introduce a user-facing change?
```release-note
None
```
  • Loading branch information
LIlGG committed Sep 18, 2024
1 parent a2b7fe2 commit d449d7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion docs/developer-guide/form-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ spec:
* 从 items 中解析出 value 的字段名,默认为 `value`。
*/
valueField?: PropertyPath;

/**
* 使用 value 查询详细信息时,fieldSelector 的查询参数 key,默认为 `metadata.name`。
*/
fieldSelectorKey?: PropertyPath;
};
remoteOptimize?: boolean;
allowCreate?: boolean;
Expand Down Expand Up @@ -187,13 +192,14 @@ spec:
itemsField: items
labelField: post.spec.title
valueField: post.metadata.name
fieldSelectorKey: metadata.name
```

:::tip
当远程数据具有分页时,可能会出现默认选项不在第一页的情况,此时 Select 组件将会发送另一个查询请求,以获取默认选项的数据。此接口会携带如下参数:

```ts
fieldSelector: `${requestOption.valueField}=(value1,value2,value3)`
fieldSelector: `${requestOption.fieldSelectorKey}=(value1,value2,value3)`
```

其中,value1, value2, value3 为默认选项的值。返回值与查询一致,通过 `requestOption` 解析。
Expand Down
10 changes: 9 additions & 1 deletion versioned_docs/version-2.19/developer-guide/form-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ spec:
* 从 items 中解析出 value 的字段名,默认为 `value`。
*/
valueField?: PropertyPath;

/**
* 使用 value 查询详细信息时,fieldSelector 的查询参数 key,默认为 `metadata.name`。
*
* 需要 Halo 版本 >= 2.19.2。
*/
fieldSelectorKey?: PropertyPath;
};
remoteOptimize?: boolean;
allowCreate?: boolean;
Expand Down Expand Up @@ -187,13 +194,14 @@ spec:
itemsField: items
labelField: post.spec.title
valueField: post.metadata.name
fieldSelectorKey: metadata.name
```

:::tip
当远程数据具有分页时,可能会出现默认选项不在第一页的情况,此时 Select 组件将会发送另一个查询请求,以获取默认选项的数据。此接口会携带如下参数:

```ts
fieldSelector: `${requestOption.valueField}=(value1,value2,value3)`
fieldSelector: `${requestOption.fieldSelectorKey}=(value1,value2,value3)`
```

其中,value1, value2, value3 为默认选项的值。返回值与查询一致,通过 `requestOption` 解析。
Expand Down

0 comments on commit d449d7c

Please sign in to comment.