import DynamicChoiceInput from "@arcgis/core/form/elements/inputs/DynamicChoiceInput.js";
Inheritance
DynamicChoiceInput→SingleChoiceInput→Input→Accessor
Since
ArcGIS Maps SDK for JavaScript 5.2

The DynamicChoiceInput class defines the desired user interface for a dynamic choice group input. It lets users select a field value from a list of choices generated by an Arcade expression, rather than a fixed list. It is supported in both single and batch feature editing. Use a dynamic choice input when the available options depend on the feature being edited, values entered in other fields, or data queried from another layer or table.

This FieldElement.input is used in field elements that are set within a feature layer's formTemplate. This is displayed within the Editor.

To configure a dynamic choice input, set its choiceExpression to the name of an Arcade expression in the form template's FormTemplate.expressionInfos. The expression returns a dictionary containing a choices array, where each choice has a name for its display text and a code for the value stored in the field.

See also
Example
// Creates a new dynamic choice input for a field element within a form
const dynamicChoiceInput = new DynamicChoiceInput({
choiceExpression: dynamicChoiceExpression.name, // reference to the defined expression
noValueOptionLabel: "No Value (null)", // label for the option representing a null value
showNoValueOption: false, // whether to display the choice representing a null value (i.e., "No Value")
});

Constructors

Constructor

Constructor

Parameters

ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
PropertyTypeClass
readonly inherited
inherited
inherited
readonly
"dynamic-choice"

choiceExpression

Property
Type
string | null | undefined

A reference to an Arcade expression that returns a dictionary. The dictionary should have a choices array of objects, with each object in the array having a name property that is the text displayed to the user, and a code property that is the value assigned to the field when that choice is selected.

See also
Example
// Set the choice expression for the dynamic choice input
fieldElement.input = new DynamicChoiceInput({
choiceExpression: dynamicChoiceExpression.name
});
const dynamicChoiceExpression = new ExpressionInfo({
name: "dynamic-material-choices",
title: "Dynamic material choices",
expression:
`var choices = [
{ name: "Unknown", code: 0 },
{ name: "Cast Iron - CAS", code: 83 },
{ name: "Copper - COP", code: 84 },
{ name: "Ductile Iron - DIP", code: 88 },
{ name: "Polyvinyl Chloride - PVC", code: 94 },
{ name: "Lead - LP", code: 109 }
];
return {
choices: choices
};`,
returnType: "dictionary",
});

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

noValueOptionLabel

inherited Property
Type
string | null | undefined
Inherited from: SingleChoiceInput

The text used to represent a null value.

showNoValueOption

inherited Property
Type
boolean
Inherited from: SingleChoiceInput

Determines whether a null value option is displayed.

This only applies to fields that support null values.

Default value
true

type

readonly Property
Type
"dynamic-choice"

The type of form element input.

Methods

MethodSignatureClass
inherited static
fromJSON(json: any): any
clone(): DynamicChoiceInput
inherited
toJSON(): any

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameters

ParameterTypeDescriptionRequired
json
any

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns
any

Returns a new instance of this class.

clone

Method
Signature
clone (): DynamicChoiceInput

Creates a deep clone of the DynamicChoiceInput class.

Returns
DynamicChoiceInput

A deep clone of the DynamicChoiceInput instance.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
any

The ArcGIS portal JSON representation of an instance of this class.