import "@arcgis/map-components/components/arcgis-feature-form";- Inheritance:
- ArcgisFeatureForm→
PublicLitElement
Demo
Properties
| Property | Attribute | Type |
|---|---|---|
auto-destroy-disabled | ||
disabled | ||
edit-type | ||
| ||
| ||
group-display | "all" | "sequential" | |
heading-level | ||
hide-read-only-notice | ||
icon | Icon["icon"] | |
label | ||
| ||
| ||
reference-element | ||
state readonly | | |
time-zone |
autoDestroyDisabled
- Type
- boolean
If true, the component will not be destroyed automatically when it is disconnected from the document. This is useful when you want to move the component to a different place on the page, or temporarily hide it. If this is set, make sure to call the destroy() method when you are done to prevent memory leaks.
- Attribute
- auto-destroy-disabled
- Default value
- false
disabled
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 5.0
When true, the component is visually withdrawn and cannot receive user interaction.
- Attribute
- disabled
- Default value
- false
editType
- Type
- EditType
- Since
- ArcGIS Maps SDK for JavaScript 4.33
The edit type for the form, which determines the editing context and behavior.
This property is used in two primary ways:
-
Arcade Expressions Context: When evaluating Arcade expressions, the value of this property is assigned to the
$editContext.editTypevariable. This allows Arcade expressions to adapt their behavior based on the type of edit being performed (e.g., "INSERT", "UPDATE", "DELETE", or "NA"). -
Layer Editing Capabilities: This property is also used to determine whether the layer allows the specified type of edit. For example:
- If
editTypeis set to"INSERT"but the layer hassupportsAdd: false, all inputs in the form will be read-only. - If
editTypeis set to"UPDATE"but the layer hassupportsUpdate: false, all inputs will also be read-only.
- If
This behavior applies regardless of whether a form template or Arcade expressions are present. For instance:
- If a layer has
{ supportsAdd: true, supportsUpdate: false }and no form template, settingeditTypeto"INSERT"will allow the user to modify all fields, while setting it to"UPDATE"will make all fields read-only. - If a form template is present with field elements that include
editableExpressionorvalueExpression, theeditTypestill determines whether the layer permits editing in the given context.
- Attribute
- edit-type
- Default value
- "NA"
feature
The associated feature containing the editable attributes.
A common way to access this is via the MapView#hitTest()
or SceneView's hitTest()
method.
Example
// Check if a user clicked on an incident feature.view.on("click", function(event) { view.hitTest(event).then(function(response) { // Display the attributes of selected incident feature in the form if (response.results[0].graphic && response.results[0].graphic.layer.id == "incidentsLayer") { formVM.feature = result.results[0].graphic } });}); formTemplate
- Type
- FormTemplate | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.16
The associated template used for the form.
The FormTemplate is used to configure how the form should display and set any associated properties for the form, e.g. title, description, field elements, etc.
Example
// Create the Form template and pass in elementsconst formTemplate = new FormTemplate({ title: "Inspector report", description: "Enter all relevant information below", elements: [groupElement] // Add the grouped elements to the template});
// Add a new feature form with grouped fieldsconst form = new FeatureForm({ container: "form", groupDisplay: "sequential", // only display one group at a time formTemplate: formTemplate // set it to template created above}); groupDisplay
- Type
- "all" | "sequential"
- Since
- ArcGIS Maps SDK for JavaScript 4.10
String indicating the groupDisplay and how they will be displayed to the end user. This only applies if using grouped field elements configured in the Editor's layer infos.
Possible Values
| Value | Description |
|---|---|
| all | All groups will be expanded. |
| sequential | A single group will be expanded at a time. |
- Attribute
- group-display
- Default value
- "all"
headingLevel
- Type
- HeadingLevel
- Since
- ArcGIS Maps SDK for JavaScript 4.20
Indicates the heading level to use for the FormTemplate#title of the form.
By default, the title is rendered as a level 2 heading (e.g. <h2>Form title</h2>).
In addition, group element labels default to a level 3 heading (e.g. <h3>Group element label</h3>).
Depending on the component's placement
in your app, you may need to adjust this heading for proper semantics. This is
important for meeting accessibility standards.
- See also
- Attribute
- heading-level
- Default value
- 2
Example
// form title will render as an <h3>// group element labels will render as an <h4>featureForm.headingLevel = 3; icon
- Type
- Icon["icon"]
- Since
- ArcGIS Maps SDK for JavaScript 4.27
Icon which represents the component. Typically used when the component is controlled by another component (e.g. by the Expand component).
- See also
- Attribute
- icon
- Default value
- "form-field"
label
- Type
- string
- Since
- ArcGIS Maps SDK for JavaScript 4.11
The component's default label.
- Attribute
- label
layer
- Type
- FeatureFormLayerUnion | null | undefined
Layer containing the editable feature attributes. If this layer is not specified, it is the same as the graphic's layer.
Example
const form = new FeatureForm({ container: "formDiv", // HTML div layer: featureLayer // Feature layer}); map
- Since
- ArcGIS Maps SDK for JavaScript 5.0
A map is required when the input layer has a popupTemplate that contains Arcade expressions in ExpressionInfo or ExpressionContent that may use the $map profile variable to access data from layers within a map. Without a map, expressions that use $map will throw an error.
- Default value
- null
Example
// The building footprints represent the buildings that intersect a clicked parcel let buildingFootprints = Intersects($feature, FeatureSetByName($map, "Building Footprints"));
referenceElement
- Type
- ArcgisReferenceElement | string | undefined
By assigning the id attribute of the Map or Scene component to this property, you can position a child component anywhere in the DOM while still maintaining a connection to the Map or Scene.
- Attribute
- reference-element
timeZone
- Type
- string
- Since
- ArcGIS Maps SDK for JavaScript 4.28
The timezone displayed within the form. If unknown, it first checks if the layer has a FeatureLayer#preferredTimeZone. If so, it displays this. If not, it will default to UTC.
- Attribute
- time-zone
Methods
| Method | Signature |
|---|---|
componentOnReady inherited | componentOnReady(): Promise<this> |
destroy(): Promise<void> | |
getValues(): Promise<any> | |
submit(): Promise<void> |
componentOnReady
- Signature
-
componentOnReady (): Promise<this>
Creates a promise that resolves once the component is fully loaded.
- Returns
- Promise<this>
Example
const arcgisFeatureForm = document.querySelector("arcgis-feature-form");document.body.append(arcgisFeatureForm);await arcgisFeatureForm.componentOnReady();console.log("arcgis-feature-form is ready to go!");Events
| Name | Type |
|---|---|
| CustomEvent<{ name: "state"; }> | |
arcgisPropertyChange
arcgisPropertyChange: CustomEvent<{ name: "state"; }> Emitted when the value of a property is changed. Use this to listen to changes to properties.
arcgisReady
arcgisReady: CustomEvent<void> Emitted when the component associated with a map or scene view is ready to be interacted with.
arcgisSubmit
arcgisSubmit: CustomEvent<SubmitEvent> Fires when the submit() method is called.
arcgisValueChange
arcgisValueChange: CustomEvent<ValueChangeEvent> Fires when a field value is updated.