-
class
arcgis.mapping.forms.FormCollection(parent) Bases:
objectRepresents a collection of forms in a webmap or item. A form is the editable counterpart to a popup – it controls the appearance and behavior of your data collection experience in ArcGIS Field Maps and Map Viewer Beta. These forms can then be used in the ArcGIS Field Maps mobile app and other applications. A form is stored as “formInfo” in the layer JSON on the webmap. This class will create a
FormInfoobject for each layer or table in the webmap/item data and return it as a list. You can then modify theFormInfoobject to add and edit your form.Parameter
Description
parent
Required
WebMaporItem. This is the object which contains the layer, either an item of typeFeature Layer Collectionor aWeb Map, where the forms are located. This is needed to save your form changes to the backend.# USAGE EXAMPLE 1: Get Form Collection from WebMap wm = arcgis.mapping.WebMap(item) wm.add_layer(manhole_inspection) # get forms from webmap, get individual form from FormCollection, modify form form_collection = wm.forms form_info_2 = form_collection[0] form_info = form_collection.get(title="Manhole Inspection") form_info.clear() form_info.add_field(field_name="inspector", label="Inspector", description="This is the inspector") form_info.add_group(label="Group 1",initial_state="collapsed") form_info.update() # USAGE EXAMPLE 2: Create Form Collection from arcgis.mapping.forms import FormCollection wm = arcgis.mapping.WebMap(item) form_collection = FormCollection(wm) form_info_1 = form_collection.get(item_id="232323232323232323") form_info_1.title = "New Form"
-
get(item_id=None, title=None, layer_id=None) Returns the form for the first layer with a matching item_id, title, or layer_id in the webmap’s operational layers. Pass one of the three parameters into the method to return the form.
Parameter
Description
item_id
Optional
str. Pass the item_id for the layer or table whose form you’d like to return.title
Optional
str. Pass the title for the layer or table whose form you’d like to return.layer_id
Optional
str. Pass the layer_id for the layer whose form you’d like to return- Returns
FormInfoor None
-
FormInfo
-
class
arcgis.mapping.forms.FormInfo(layer_data, parent, subtype_gl_data=None, **kwargs) Bases:
objectRepresents a form in ArcGIS Field Maps and other applications. This matches with the formInfo property in a webmap’s operational layer.
For more please see: https://developers.arcgis.com/web-map-specification/objects/formInfo/
Parameter
Description
layer_data
Required
PropertyMapordict. This is the operational layer which contains the formInfo dict. It can be retrieved from a webmap using arcgis.mapping.WebMap(item).layers[0]parent
Required
WebMaporItem. This is the object which contains the layer, either an item of type Feature Layer Collection or a webmap. This is needed to save your form changes to the backend.subtype_gl_data
Optional
PropertyMapordict. This is the operational layer representing a subtype group layer which contains the layer containing the form. It can be retrieved from a webmap using arcgis.mapping.WebMap(item).layers[0]# USAGE EXAMPLE 1: Modify FormInfo from arcgis.mapping.forms import FormFieldElement wm = arcgis.mapping.WebMap(item) wm.add_layer(manhole_inspection) form_collection = wm.forms form_info = form_collection.get_form(title="Manhole Inspection") # edit form properties form_info.title = "Manhole Inspection Form" form_info.description = "The editable experience in ArcGIS Field Maps for data collection" # get element, add element new_element = FormFieldElement(label="Inspector Name", field_name="inspectornm", editable=True) form_info.add(element=new_element) same_element = form_info.get(label="Inspector Name") # add group, add second group, add to group form_info.add_group(label="Inspector Group",description="This is a group for inspectors") new_group = FormGroupElement(label="Group 1", description="New Group") group = form_info.add(element=new_group) group.add_field(field_name="inspection_date", label="Inspection Date") # move element, delete element form_info.move(element=new_group, index=0) form_info.delete(element=new_group) # save form into backend form_info.update()
-
add(element=None, index=None) Adds a single
FormElementto the form. You can add to the form either by instantiating your ownFormFieldElementorFormGroupElementand passing it into the element parameter here, or you can type in a valid field_name in the form’s layer and this function will attempt to add it to the form.Parameter
Description
element
Optional
FormFieldElementorFormGroupElement.index
Optional
int. The index where you’d like the element in the form. If not provided, this function will add the new element to the end of the form.- Returns
The element that was added -
FormFieldElementorFormGroupElement
-
add_all_attributes() Adds all fields which can be valid form elements (string, date, int, double, small) to the form.
-
add_field(field_name, label, description=None, visibility_expression=None, domain=None, editable=None, hint=None, input_type=None, required_expression=None, index=None, editable_expression=None, value_expression=None, **kwargs) Adds a single field
FormElementelement to the end of the form.For more please see: https://developers.arcgis.com/web-map-specification/objects/formFieldElement/
Parameter
Description
field_name
Required
str. The field name the form element corresponds to (where the data will be collected)label
Required
str. The label of the form elementdescription
Optional
str. The description of the form elementvisibility_expression
Optional
FormExpressionInfo. The conditional visibility Arcade expression determining the visibility of the form element during data collectiondomain
Optional
dict. The domain of the form elementeditable
Optional
bool. Whether or not the form element is editablehint
Optional
str. The hint for the user filling out the form elementinput_type
Optional
strordict. The input type for the form element in ArcGIS Field Maps. Options include: “text-area”, “text-box”, “barcode-scanner”, “combo-box”, “radio-buttons”, “datetime-picker”required_expression
Optional
FormExpressionInfo. The conditional visibility Arcade expression determining the necessity of the form element during data collectionindex
Optional
int. The index where you’d like the element in the form. If not provided, this function will add the new element to the end of the form.editable_expression
Optional
FormExpressionInfo. The Arcade expression determining the editablity of the form element during data collectionvalue_expression
Optional
FormExpressionInfo. The Arcade expression which calculates a value for the form element during data collection- Returns
The element that was added -
FormGroupElement
-
add_group(label, description=None, visibility_expression=None, initial_state=None, index=None, **kwargs) Adds a single
GroupElementto the formParameter
Description
label
Required
str. The label of the groupdescription
Optional
str. The description of the groupvisibility_expression
Optional
FormExpressionInfo. The conditional visibility Arcade expression determining the visibility of the form element during data collectioninitial_state
Optional
str. The initial state of the groupindex
Optional
int. The index where you’d like the element in the form. If not provided, this function will add the new element to the end of the form.- Returns
The element that was added -
FormGroupElement
-
delete(element=None, label=None) Deletes element from the form. You can use either the element param with a form element you get using
get()or you can pass the label of the form element you’d like to move into the label param.Parameter
Description
element
Optional
FormFieldElementorFormGroupElementlabel
Optional
str. An actual field name (not alias) corresponding to a field in the form’s feature layer- Returns
FormFieldElementorFormGroupElementor False
-
property
elements Returns elements in the form to the user - a list of
FormElement
-
property
expressions Returns Arcade expressions used in the form to the user - a list of
FormExpressionInfo
-
get(label=None) Returns a matching FormElement given a label
Parameter
Description
label
Optional
strThe label of the form element you want to return from the list of form elements- Returns
FormFieldElementorFormGroupElementor None
-
FormElement
-
class
arcgis.mapping.forms.FormElement(form=None, element_type=None, description=None, label=None, visibility_expression=None, **kwargs) Bases:
objectThe superclass class for
FormFieldElementandFormGroupElement. Contains properties common to the two types of field elements. Instantiate a FormFieldElement or FormGroupElement instead of this class.
FormFieldElement
-
class
arcgis.mapping.forms.FormFieldElement(form=None, description=None, label=None, visibility_expression=None, domain=None, editable=None, field_name=None, hint=None, input_type=None, required_expression=None, editable_expression=None, value_expression=None, **kwargs) Bases:
arcgis.mapping.forms.FormElementRepresents a single field (non-group) element in a form. This corresponds with a field in the feature layer where you are collecting data. This is a subclass of FormElement, so you can modify properties such as label, description, and visibility_expression on these objects as well.
For more please see: https://developers.arcgis.com/web-map-specification/objects/formFieldElement/
Parameter
Description
form
Optional
FormInfo. The form which contains this field element.description
Optional
str. The description of the form elementlabel
Optional
str. The label of the form elementvisibility_expression
Optional
FormExpressionInfo. The conditional visibility Arcade expression determining the visibility of the form element during data collectiondomain
Optional
dict. The domain of the form elementeditable
Optional
bool. Whether or not the form element is editablefield_name
Optional
str. The field name the form element corresponds to (where the data will be collected)hint
Optional
str. The hint for the user filling out the form elementinput_type
Optional
strordict. The input type for the form element in ArcGIS Field Maps.- Options include:
“text-area”, “text-box”, “barcode-scanner”, “combo-box”, “radio-buttons”, “datetime-picker”
required_expression
Optional
FormExpressionInfo. The conditional visibility Arcade expression determining the necessity of the form element during data collection# USAGE EXAMPLE 1: Edit properties on form element from arcgis.mapping.forms import FormExpressionInfo wm = arcgis.mapping.WebMap(item) wm.add_layer(manhole_inspection) form_collection = wm.forms form_info = form_collection.get_form(title="Manhole Inspection") # edit element properties form_element = form_info.get(label="Inspector Name") form_element.label = "Inspector Name(s)" form_element.description = "The inspector(s) who completed this manhole inspection") # set visibility expression el = form_info.add_field(field_name="jake_only", label="jake_only") expression_info = FormExpressionInfo(name="expr0",title="New Expression",expression="$feature.inspector == 'Jake'") el.visibility_expression = expression_info
-
property
editable_expression Gets/sets the editable expression of the form element. Takes an object of
FormExpressionInfo.
-
property
input_type Gets/sets the input type of the form element.
Parameter
Description
value
Required string or dictionary.
Values:
“text-area” | “text-box” | “barcode-scanner” | “combo-box” | “radio-buttons” | “datetime-picker”
- Returns
dictionary that represents the input type
-
property
required_expression Gets/sets the required expression of the form element. Takes an object of
FormExpressionInfo.
-
property
value_expression Gets/sets the value expression of the form element. Takes an object of
FormExpressionInfo.
FormGroupElement
-
class
arcgis.mapping.forms.FormGroupElement(form=None, elements=None, initial_state=None, description=None, label=None, visibility_expression=None, **kwargs) Bases:
arcgis.mapping.forms.FormElementRepresents a single group element in a form. This is a subclass of FormElement, so you can modify properties such as label, description, and visibility_expression on these objects as well.
For more please see: https://developers.arcgis.com/web-map-specification/objects/formGroupElement/
Parameter
Description
form
Optional
FormInfo. The form which contains this group element.description
Optional
str. The description of the group elementlabel
Optional
str. The label of the group elementvisibility_expression
Optional
FormExpressionInfo. The conditional visibility Arcade expression determining the visibility of the form element during data collectioninitial_state
Optional
dict. Options are “collapsed” and “expanded”# USAGE EXAMPLE 1: Edit properties on group, add to group from arcgis.mapping.forms import FormExpressionInfo wm = arcgis.mapping.WebMap(item) wm.add_layer(manhole_inspection) form_collection = wm.forms form_info = form_collection.get_form(title="Manhole Inspection") # edit group properties, access elements within group group_element = form_info.get(label="Group 1") grouped_form_element = group_element.get(label="Inspector Name") grouped_form_element.label = "Inspector Name(s) group_element.label = "Inspector Information" group_element.initial_state = "collapsed" # add group, add to group, delete from group, delete group new_group = FormGroupElement(form_info, label="Group 2", initial_state="expanded") group = form_info.add(element=new_group) grouped_element = group.add_field(field_name="inspection_date", label="Inspection Date") group.add_field(field_name="inspection_city", label="Inspection City") grouped_element.label = "Inspection Date" group.move(grouped_element, index=1) group.delete(grouped_element) form_info.delete(group)
-
add(element=None, index=None) Adds a single form element to the group. You can add to the group either by instantiating a FormFieldElement and passing it into the element parameter here, or you can type in a valid field_name in the form’s layer and this function will attempt to add it to the form.
Parameter
Description
element
Optional
FormFieldElementindex
Optional
int. The index where you’d like the element in the group. If not provided, this function will add the new element to the end of the group.- Returns
The element that was added -
FormFieldElement
-
add_field(field_name, label, description=None, visibility_expression=None, domain=None, editable=None, hint=None, input_type=None, required_expression=None, index=None, editable_expression=None, value_expression=None, **kwargs) Adds a single field
FormElementelement to the end of the group.For more please see: https://developers.arcgis.com/web-map-specification/objects/formFieldElement/
Parameter
Description
field_name
Required
str. The field name the form element corresponds to (where the data will be collected)label
Required
str. The label of the form elementdescription
Optional
str. The description of the form elementvisibility_expression
Optional
FormExpressionInfo. The conditional visibility Arcade expression determining the visibility of the form element during data collectiondomain
Optional
dict. The domain of the form elementeditable
Optional
bool. Whether or not the form element is editablehint
Optional
str. The hint for the user filling out the form elementinput_type
Optional
strordict. The input type for the form element in ArcGIS Field Maps. Options include: “text-area”, “text-box”, “barcode-scanner”, “combo-box”, “radio-buttons”, “datetime-picker”required_expression
Optional
FormExpressionInfo. The conditional visibility Arcade expression determining the necessity of the form element during data collectionindex
Optional
int. The index where you’d like the element in the form. If not provided, this function will add the new element to the end of the form.editable_expression
Optional
FormExpressionInfo. The Arcade expression determining how much editable the form element is during data collectionvalue_expression
Optional
FormExpressionInfo. The Arcade expression which calculates a value for the form element during data collection
-
delete(element=None, label=None) Deletes form element from the group. You can use either the element param with a form element you get using FormInfo.get() or you can pass the label of the form element you’d like to move into the label param.
Parameter
Description
element
Optional
FormFieldElementlabel
Optional
strAn actual field name (not alias) corresponding to a field in the form’s feature layer- Returns
The deleted element -
FormFieldElementor False
-
property
elements Returns elements in the group to the user - a list of
FormElement.
-
get(label=None) Returns a matching FormFieldElement in the group given a label
Parameter
Description
label
Optional
strThe label of the form element you want to return from the list of form elements- Returns
FormFieldElementor None
-
property
initial_state Gets/sets the initial state of the form element.
Parameter
Description
value
Required string.
Values:
“collapsed” | “expanded”
-
move(element=None, label=None, destination=None, index=None) Moves a form element in the group to a new location. You can use either the element param with a form element you get using FormGroupElement.get() <:attr:`arcgis.mapping.forms.FormGroupElement.get>` or you can pass the label of the form element you’d like to move into the label param.
- Returns
The element that was moved -
FormFieldElement
-
FormExpressionInfo
-
class
arcgis.mapping.forms.FormExpressionInfo(expression=None, name=None, title=None, return_type='boolean', **kwargs) Bases:
objectThis class corresponds to a single expressionInfo in the expressionInfos list within a form.
For more please see: https://developers.arcgis.com/web-map-specification/objects/formExpressionInfo/
Parameter
Description
expression
Optional
strThis is an Arcade expression which you want to evaluate in ArcGIS Field Maps on whether or not this form element shows.name
Optional
strThe unique identifier for the expressionInfotitle
Optional
int. The user friendly name for the expressionInforeturn_type
Optional
str. The return type of the expression in expressionInfo