Auto-populating fields(自动填充字段)¶
:::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. :::
You can capture metadata about a form, such as who created the response and when, by using auto-populating form fields. This page discusses the seven types of auto-populating fields available when adding a field to your form.
Calculation¶
The calculation field displays a calculated value based on other single-value fields. Users can configure the following options:
- Create a formula that references the value of other fields.
- Customize the value stored when the formula evaluates to
NaN,infinity, or other errors. - Specify an
Output(Number, Date, or Timestamp). - Set a
Number precision. - Provide a
Default missing valuefor each parameter. - Set a
Unit label(for example,kgorlbs). - Use the Code Editor to set
placeholder: string.
:::callout{theme="neutral"} Users can create any formula supported by the expr-eval library ↗. :::
Created at¶
The created at field displays the entry's time of creation or modification. Users can configure the following options:
- Specify the
Recorded format(for example, "YYYY/MM/DD" or "DD.MM.YYYY"). - Record the value as a timestamp that also represents the timezone, or as a simple representation that stores whatever the time is at that location.
- Record the time the form is opened rather than submitted.
:::callout{theme="neutral"}
If you toggle on Record as local date or timestamp in the field configuration, the field will store whatever the time is in the timezone the user is in. Therefore, the time on different entries may not represent the order in which they actually occurred. You can express what timezone the entry was created in if you include the z option in the timestamp format.
:::
The created at field can be useful for tracking which entries are the most recent, how many entries are being created over time, or at what time of day they tend to get created.
Created by¶
The created by field displays the user ID of the entry's creator or modifier.
This field can be used in combination with a user attributes field to get the current user's name or email address.
Modified at¶
The modified at field displays the entry's latest time of modification. Users can configure the following options:
- Specify the
Recorded format(for example, "YYYY/MM/DD" or "DD.MM.YYYY"). - Record the value as a timestamp that also represents the timezone, or as a simple representation that stores whatever the time is at that location.
- Record the time the form was opened rather than submitted.
:::callout{theme="neutral"}
If you toggle on Record as local date or timestamp in the field configuration, the field will store whatever the time is in the timezone the user is in. Therefore, the time on different entries may not represent the order in which they actually occurred. You can express what timezone the entry was created in if you include the z option in the timestamp format.
:::
The modified at field can be useful for tracking which entries are the most recent, how often entries are being edited, or what has changed since creation and requires downstream updates.
Modified by¶
The modified by field displays the user ID of the entry's modifier.
This field can be used in combination with a user attributes field to get the current user's name or email address.
Template¶
The template field displays a concatenated value based on the value of other, single-value fields. Users can configure the following options:
- Create a template that references the value of other fields.
- Use the Code Editor to set
placeholder: stringanderrorValue: string.
Examples¶
-
Suppose you want to combine a score field and comment field in a survey. You could target "score" as variable
aand "comment" asb. From there, create the template{{a}} - {{b}}and get results of the form5 - very satisfied. -
To use the property of an object referenced in the form, you can use an object property display field to select the property, hide that field, and reference it from the template field.
-
You can use a field configuration transform to change which fields or format the template uses based on other conditions on the values in the form. For example, you could ask respondents to select a standard response from a dropdown or let them write a custom response in a text field. A different template will be used depending on the action of the respondent.
中文翻译¶
自动填充字段¶
:::callout{theme="warning"} Foundry Forms 已不再是 Foundry 上数据录入或回写工作流的推荐方案。请改用 Foundry Ontology 构建用户输入工作流,将相关数据结构表示为对象类型,并通过 Actions 配置回写交互。更多信息请参阅 Forms 概述 文档。 :::
您可以通过使用自动填充表单字段来捕获表单的元数据,例如谁创建了响应以及何时创建。本页讨论在表单中添加字段时可用的七种自动填充字段类型。
计算 (Calculation)¶
计算 字段基于其他单值字段显示计算值。用户可以配置以下选项:
- 创建引用其他字段值的公式。
- 自定义当公式计算结果为
NaN、infinity或其他错误时存储的值。 - 指定
输出(数字、日期或时间戳)。 - 设置
数字精度。 - 为每个参数提供
默认缺失值。 - 设置
单位标签(例如kg或lbs)。 - 使用 代码编辑器 设置
placeholder: string。
:::callout{theme="neutral"} 用户可以创建 expr-eval 库 ↗ 支持的任何公式。 :::
创建时间 (Created at)¶
创建时间 字段显示条目的创建或修改时间。用户可以配置以下选项:
- 指定
记录格式(例如 "YYYY/MM/DD" 或 "DD.MM.YYYY")。 - 将值记录为同时表示时区的时间戳,或记录为仅存储该位置当前时间的简单表示。
- 记录表单打开的时间而非提交的时间。
:::callout{theme="neutral"}
如果在字段配置中开启 记录为本地日期或时间戳,该字段将存储用户所在时区的当前时间。因此,不同条目的时间可能无法反映它们实际发生的顺序。如果在时间戳格式中包含 z 选项,则可以表示条目创建时的时区。
:::
创建时间 字段可用于追踪哪些条目是最新的、随时间推移创建了多少条目,或者条目通常在一天中的什么时间被创建。
创建者 (Created by)¶
创建者 字段显示条目创建者或修改者的用户 ID。
此字段可与用户属性字段结合使用,以获取当前用户的姓名或电子邮件地址。
修改时间 (Modified at)¶
修改时间 字段显示条目的最新修改时间。用户可以配置以下选项:
- 指定
记录格式(例如 "YYYY/MM/DD" 或 "DD.MM.YYYY")。 - 将值记录为同时表示时区的时间戳,或记录为仅存储该位置当前时间的简单表示。
- 记录表单打开的时间而非提交的时间。
:::callout{theme="neutral"}
如果在字段配置中开启 记录为本地日期或时间戳,该字段将存储用户所在时区的当前时间。因此,不同条目的时间可能无法反映它们实际发生的顺序。如果在时间戳格式中包含 z 选项,则可以表示条目创建时的时区。
:::
修改时间 字段可用于追踪哪些条目是最新的、条目被编辑的频率,或者自创建以来发生了哪些需要下游更新的变化。
修改者 (Modified by)¶
修改者 字段显示条目修改者的用户 ID。
此字段可与用户属性字段结合使用,以获取当前用户的姓名或电子邮件地址。
模板 (Template)¶
模板 字段基于其他单值字段的值显示拼接后的值。用户可以配置以下选项:
- 创建引用其他字段值的模板。
- 使用 代码编辑器 设置
placeholder: string和errorValue: string。
示例¶
-
假设您想将调查中的评分字段和评论文本字段结合起来。您可以将 "score" 设为变量
a,将 "comment" 设为b。然后创建模板{{a}} - {{b}},得到类似5 - very satisfied的结果。 -
要使用表单中引用的对象的属性,您可以使用对象属性显示字段来选择该属性,隐藏该字段,然后从模板字段中引用它。
-
您可以使用字段配置转换,根据表单中值的其他条件来更改模板使用的字段或格式。例如,您可以要求受访者从下拉菜单中选择标准回复,或者让他们在文本字段中编写自定义回复。根据受访者的操作,将使用不同的模板。