The Forms SDK provides a set of directives which simplify working with process variables in an HTML form.These directives work on most of the HTML controls and allow users to declaratively fetch variables from the process engine and have their values written to and read from input fields.

If an HTML control is not supported, you need to write custom JavaScript.

The cam-variable-name Directive

The cam-variable-name directive allows providing the name of a process / task / case variable. If the directive is discovered on an HTML control, the value of the variable is fetched from the server and written to the control.

  1. <input type="text"
  2. cam-variable-name="CUSTOMER_ID">

The cam-business-key Directive

The cam-business-key is aimed to be used on a free text input field in order to define a businessKey at the start of a process.This attribute is only relevant when the form is aimed to start a process.

  1. <input type="text"
  2. cam-business-key>

See also: Setting the business key using Javascript

AngularJS support and cam-variable-name

If you use the AngularJS integration, the cam-variable-name directive will automatically bind the input to the model in case no binding is provided by the user.

The following two markup examples have the same semantics:

  1. <input type="text"
  2. cam-variable-name="CUSTOMER_ID">

is the same as

  1. <input type="text"
  2. cam-variable-name="CUSTOMER_ID"
  3. ng-model="CUSTOMER_ID">

If the user provides a customer ng-model binding, it is respected:

  1. <input type="text"
  2. cam-variable-name="CUSTOMER_ID"
  3. ng-model="customerId">
  4. Current value: {{customerId}}

The cam-variable-type Directive

The cam-variable-type directive allows specifying the type of a process / task / case variable. This is required if the variable does not yet exist.

The following markup creates a text input field bound to a variable of type Double:

  1. <input type="text"
  2. cam-variable-name="INVOICE_AMOUNT"
  3. cam-variable-type="Double">

Supported Variable Types

See the section on variable types for a list of variable types which are supported out of the box.

AngularJS Support and cam-variable-type

The cam-variable-type directive can be used as validation directive:

  1. <input type="text"
  2. name="invoiceAmount"
  3. cam-variable-name="INVOICE_AMOUNT"
  4. cam-variable-type="Double">
  5. <span ng-show="myForm.invoiceAmount.$error.camVariableType">
  6. Input must be a 'Double'.
  7. </span>

原文: https://docs.camunda.org/manual/7.9/reference/embedded-forms/controls/