跳转至

Transforms(转换(Transforms))

:::callout{theme="warning"} Foundry Forms is no longer the recommended approach for data entry or writeback workflows on Foundry. Instead, build user input workflows with the Foundry Ontology, representing the relevant data structures as object types and configuring the writeback interaction with Actions. Learn more in the Forms overview documentation. :::

Transforms are a set of tools that allow users to create dynamic dependencies within their forms. In specifying conditional modifications to fields, users are able to direct data from respondents more efficiently and accurately.

Transforms can be accessed after creating and configuring a new field. There are five types of transforms, all of which can be combined to create different outcomes for respondents as they fill out the form.

Hide field

The hide field transform allows users to hide a field from respondents based on the values of other fields. By reducing the clutter of inapplicable fields, this transform can help move respondents through the form more quickly.

Example

Hide Field B if Field A has value X.

Show field

The show field transform allows users to show a field to respondents based on the values of other fields. Similar to hide field, this transform can help move respondents through the form more quickly, offering only applicable fields.

Example

Show Field B if Field A has value X.

Disable field

The disable field transforms allows users to disable a field based on the values of other fields. Unlike with the hide field transform, fields transformed with the disable field transform will still be visible; those fields can be configured to display important information to respondents, guiding them to other fields that are either unanswered or answered in such a way that they are now blocked from entering a value.

Example

Disable Field B if Field A has value X.

Update configuration

The update configuration transform allows users to update the configuration of a field based on the values of other fields. Almost all options can be changed, excluding those that must remain constant, includingtag, uri, defaultValue, transforms themselves, and options available in Attachments fields.

Example

Add [required validator] to Field B if Field A has value X.

Change field type

The change field type transform allows users to change the type of a field based on the values of other fields.

Example

Change type of Field B to [Text Area] if Field A has value X.

Add transforms

To add a transform to a field, complete the following steps:

  1. First, double-click a field to open the Visual Editor to the right.

  2. From the Transforms tab, select Add new transform, then select a type.

    Select transform type from menu.

  3. Select the field on which the transform will be dependent (available options will be highlighted in purple).

  4. Configure the condition; for example, Has no value.

    Configure transform condition.

  5. If using an update configuration or change field type transform, define the outcome.

  6. Select the green Save button.

Create complex conditions

After adding a transform with a simple condition, a more complex condition can be created as follows:

  1. Select the pencil icon in the top right of the transform configuration in the Transforms tab of the Visual Editor.
  2. Select + below the existing condition of the transform, and choose to configure a new condition.
  3. Use the Is/Not and And/Or dropdowns to create a complex condition tree.

:::callout{theme="neutral"} Hover over the Is/Not dropdowns to understand which conditions are grouped together by And/Or. :::

Example

Show Field C if Field A has value X and Field B does not have value Y.

Define multiple transforms

Multiple transforms can be added to a single field by clicking the Add new transforms button at the bottom of the panel. Transforms are applied in the order they are defined; if there are any conflicts, the last transform takes precedence.

Example

Change [Label] of Field B to "Zip Code" if Field A has value X. Add 5-digit [regex validator] to Field B if Field A has value X.

:::callout{theme="warning"} A field should not have both a show and a hide transform. These can be consolidated to a single show transform if you want the field to be hidden by default, or a single hide transform otherwise. :::


中文翻译

转换(Transforms)

:::callout{theme="warning"} Foundry Forms 已不再是 Foundry 上数据录入或回写工作流的推荐方法。请改用 Foundry 本体论(Ontology)构建用户输入工作流,将相关数据结构表示为对象类型(Object Types),并通过操作(Actions)配置回写交互。了解更多信息,请参阅 Forms 概述 文档。 :::

转换(Transforms)是一组工具,允许用户在表单中创建动态依赖关系。通过指定对字段的条件性修改,用户可以更高效、更准确地引导受访者的数据输入。

在创建并配置新字段后即可访问转换功能。共有五种类型的转换,它们可以组合使用,为受访者填写表单时创造不同的结果。

隐藏字段(Hide field)

隐藏字段(hide field) 转换允许用户根据其他字段的值对受访者隐藏某个字段。通过减少不适用字段的干扰,此转换可以帮助受访者更快地完成表单填写。

示例

如果字段 A 的值为 X,则隐藏字段 B。

显示字段(Show field)

显示字段(show field) 转换允许用户根据其他字段的值向受访者显示某个字段。与隐藏字段(hide field)类似,此转换可以帮助受访者更快地完成表单填写,仅显示适用的字段。

示例

如果字段 A 的值为 X,则显示字段 B。

禁用字段(Disable field)

禁用字段(disable field) 转换允许用户根据其他字段的值禁用某个字段。与隐藏字段(hide field)转换不同,使用禁用字段(disable field)转换的字段仍然可见;这些字段可以配置为向受访者显示重要信息,引导他们前往其他未回答或回答方式导致其无法输入值的字段。

示例

如果字段 A 的值为 X,则禁用字段 B。

更新配置(Update configuration)

更新配置(update configuration) 转换允许用户根据其他字段的值更新某个字段的配置。几乎所有选项都可以更改,但必须保持不变的选项除外,包括标签(tag)统一资源标识符(uri)默认值(defaultValue)、转换(transforms)本身,以及附件(Attachments)字段中可用的选项。

示例

如果字段 A 的值为 X,则向字段 B 添加[必填验证器(required validator)]。

更改字段类型(Change field type)

更改字段类型(change field type) 转换允许用户根据其他字段的值更改某个字段的类型。

示例

如果字段 A 的值为 X,则将字段 B 的类型更改为[文本区域(Text Area)]。

添加转换(Add transforms)

要向字段添加转换,请完成以下步骤:

  1. 首先,双击某个字段以在右侧打开可视化编辑器(Visual Editor)。

  2. 转换(Transforms)选项卡中,选择添加新转换(Add new transform),然后选择一种类型。

    从菜单中选择转换类型。

  3. 选择转换所依赖的字段(可用选项将以紫色高亮显示)。

  4. 配置条件;例如,无值(Has no value)

    配置转换条件。

  5. 如果使用更新配置(update configuration)更改字段类型(change field type)转换,请定义结果。

  6. 选择绿色的保存(Save)按钮。

创建复杂条件(Create complex conditions)

在添加了带有简单条件的转换后,可以按如下方式创建更复杂的条件:

  1. 在可视化编辑器(Visual Editor)的转换(Transforms)选项卡中,选择转换配置右上角的铅笔图标。
  2. 在转换现有条件下方选择 +,然后选择配置新条件。
  3. 使用是/否(Is/Not)与/或(And/Or)下拉菜单创建复杂的条件树。

:::callout{theme="neutral"} 将鼠标悬停在是/否(Is/Not)下拉菜单上,以了解哪些条件通过与/或(And/Or)组合在一起。 :::

示例

如果字段 A 的值为 X 且字段 B 的值不为 Y,则显示字段 C。

定义多个转换(Define multiple transforms)

可以通过点击面板底部的添加新转换(Add new transforms)按钮向单个字段添加多个转换。转换按照定义的顺序应用;如果存在任何冲突,则最后一个转换优先。

示例

如果字段 A 的值为 X,则将字段 B 的[标签(Label)]更改为"邮政编码(Zip Code)"。如果字段 A 的值为 X,则向字段 B 添加 5 位数字的[正则表达式验证器(regex validator)]。

:::callout{theme="warning"} 一个字段不应同时包含显示(show)隐藏(hide)转换。如果您希望该字段默认隐藏,可以将它们合并为一个显示(show)转换;否则,合并为一个隐藏(hide)转换。 :::