TX Text Control .NET Server

Javascript: FormFieldCollection.addCheckFormField Method

Method|Introduced in 28.0

Description

Adds a new CheckFormField.

Syntax

<void> FormFieldCollection.addCheckFormField(<boolean> isChecked, [<RequestCheckFormFieldCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
isChecked

Specifies whether the checkbox is initially checked or unchecked. When this parameter is true, it is checked.

callback

Optional. Receives the added CheckFormField.

errorCallback

Optional. Is called when the operation failed with an error.

Examples

The following example demonstrates FormFieldCollection.addCheckFormField in a practical document-editing workflow. It adds a new CheckFormField.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(mainText) {
    const formFields = mainText.formFields;
    formFields.addCheckFormField(
        true,
        function(checkFormField) {
            if (!checkFormField) {
                console.warn("No check form field was returned.");
                return;
            }
            
            console.log("add check form field result:", checkFormField);
        },
        onTxError
    );
}, onTxError);

Further Reading