跳到主要内容

SetPlaceholderText

设置当前表单的占位符文本。

备注

无法为复选框或单选按钮表单设置占位符文本。

继承自 ApiFormBase.SetPlaceholderText。

语法​

expression.SetPlaceholderText(sText);

expression - 表示 ApiCheckBoxForm 类的变量。

参数​

名称必需/可选数据类型默认值描述
sText必需string将设置到当前表单的文本。

返回值​

boolean

示例​

在文档中为复选框表单设置占位符文本。

// How do I add hint text that appears inside a form field in a document?

// Give each form field a descriptive placeholder so users understand what to fill 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.SetPlaceholderText("Form 1");
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.SetPlaceholderText("Form 2");
paragraph.AddElement(checkBoxForm);
paragraph.AddText(" Single");
let formKey = checkBoxForm.GetFormKey();
paragraph = Api.CreateParagraph();
paragraph.AddText("Form key: " + formKey);
doc.Push(paragraph);