SetTag
Sets the tag attribute to the current form.
Inherited from ApiFormBase.SetTag.
Syntax
expression.SetTag(tag);
expression - A variable that represents an ApiCheckBoxForm class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| tag | Required | string | The tag which will be added to the current container. |
Returns
boolean
Example
Attach an identifying tag to a checkbox form in a document.
// 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);