跳到主要内容

SetTag

为当前表单设置标签属性。

继承自 ApiFormBase.SetTag。

语法​

expression.SetTag(tag);

expression - 表示 ApiCheckBoxForm 类的变量。

参数​

名称必需/可选数据类型默认值描述
tag必需string将添加到当前容器的标签。

返回值​

boolean

示例​

在文档中为复选框表单附加标识标签。

// How do I label a form field with a custom tag for later retrieval in a document?

// Store a searchable identifier on each checkbox so forms can be grouped or found programmatically in a document.

let doc = Api.GetDocument();
let checkBoxForm = Api.CreateCheckBoxForm({"tip": "Specify your marital status", "required": true, "placeholder": "Marital status", "radio": false});
checkBoxForm.SetFormKey("Marital status 1");
checkBoxForm.SetTag("Marital status");
let paragraph = doc.GetElement(0);
paragraph.AddElement(checkBoxForm);
paragraph.AddText(" Married");
paragraph.AddLineBreak();
checkBoxForm = Api.CreateCheckBoxForm({"tip": "Specify your marital status", "required": true, "placeholder": "Marital status", "radio": false});
checkBoxForm.SetFormKey("Marital status 2");
checkBoxForm.SetTag("Marital status");
paragraph.AddElement(checkBoxForm);
paragraph.AddText(" Single");
let tag = checkBoxForm.GetTag();
paragraph = Api.CreateParagraph();
paragraph.AddText("Form tag: " + tag);
doc.Push(paragraph);