Update Feature Attributes

This sample demonstrates how to use FeatureLayer.applyEdits() to update attributes of existing features. This sample uses the FeatureForm widget to update attributes of existing features by calling the applyEdits function when a user selects a feature on the view.

The form's fields are configured via a form template. This template accepts an array of field elements combined in a group. Having grouped field configurations provides a more manageable editing workflow. This sample uses nested elements which autocast to group elements.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
formTemplate: { // Autocasts to new FormTemplate
  title: "Damage assessments",
  description: "Provide information for insurance",
  elements: [
    { // Autocasts to new GroupElement
      type: "group",
      label: "Inspector Information",
      description: "Field inspector information",
      elements: [
        { // Autocasts to new FieldElement
          type: "field",
          fieldName: "inspector",
          label: "name"
        },
        {
          type: "field",
          fieldName: "inspemail",
          label: "Email address",
          visibilityExpression: "alwaysHidden" // reference to an expression defined under "expressionInfos"
        },
        {
          type: "field",
          fieldName: "insp_date",
          label: "Date of inspection"
        }
      ]
    }
  ]
}
...

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.