interactive image field
The interactive-image component can be used as a form field by setting presentation: field. In field mode, the interactive image behaves like any other form field, such as a dropdown or signature field. It has a label, a value, validation, and onChange. The selected points are submitted with the form.
In a form, the field renders as a collapsed row that shows a floating label, a summary of how many points are selected, and a read-only preview of the image. Tapping the row opens a full-height picker where the user selects points on the image. The picker shows the image with the group cards beneath it, and a pinned Cancel / Confirm footer:
Confirm commits the selection to the field's value and triggers
onChangeonce for the whole picker session.Cancel, tapping the backdrop, or swiping the picker down discards the changes and restores the selection from when the picker was opened.
The points on the image are configured with interactive-image-item, in the same way as the inline interactive image.
Configuration options
Some properties are common to all components. See Common component properties for the properties and their configuration options.
Core structure
presentation
Set to field to use the interactive image as a form field. The default is inline, which displays the image directly on the screen and does not take part in the form.
instanceId
The unique identifier of the field. The instanceId is used as the key for the field's value in the form data when the form is submitted, for example, {"damaged-parts": ["1","3"]}.
label
The label displayed on the field row. The label floats above the selection summary once points are selected.
source
The image to display, specified as a uri.
data
The datasource that provides the points displayed on the image, for example, =@ctx.datasources.vehicle-parts.
item
The interactive-image-item that configures each point, including its id, title, and percentageCoordinates. The item's id is the value stored in the field when the point is selected.
Other options
groups
Create groups to categorize the selected points, for example, Damaged or Scratched. Each group has an id, title, optional color, and optional maximumPoints that limits how many points can be added to the group. The groups display as cards in the picker, and each selected point displays as a removable tag on its group's card. If no groups are configured, the picker shows all selected points in a single Selected card.
helperText
Text displayed under the field to guide the user, for example, Tap to mark the damaged parts.
errorText
Text displayed under the field when the field is invalid.
initialValue
The point id(s) selected when the field loads. Use an array of ids when isMultiple is true, for example, ['3','1'], and a single id when isMultiple is false, for example, '2'. Seeding the field with initialValue does not mark the form as dirty.
isHidden
Hides the field when set to true. Use an expression to show or hide the field dynamically.
isMultiple
Set to false to allow only one point to be selected. Selecting a new point replaces the previously selected point, and the field's value is a single id instead of an array. The default is true.
isRequired
Set to true to make the field required. An asterisk displays next to the label until a point is selected, and the form cannot be submitted without a selection.
pointColor
The color of the points on the image that are available for selection.
style
isDisabled - disables the field so that the picker cannot be opened and the selection cannot be changed.
value
Sets the field's value, using the point id(s) in the same format as initialValue.
Actions
onChange
The action is triggered when the selection changes. When the user selects points in the picker, the action is triggered once, when the user presses Confirm, not for each point pressed. Use IntelliSense (ctrl+space) to see the list of available actions.
onBlur
The action is triggered when the field loses focus. Use IntelliSense (ctrl+space) to see the list of available actions.
State Configuration
=@ctx.component.state.
value
selected
value - the id(s) of the selected points, for example, ["1","3"], or "3" when isMultiple is false.
selected - the datasource records of the selected points, for example, =@ctx.components.damaged-parts.state.selected.title returns ["Hood","Trunk"].
=@ctx.components.form-id.state.
data
isValid
isDirty
The form state includes the interactive image field's value in data, keyed by the field's instanceId.
=@ctx.solution.state.
activeItemId now
Global state variable that can be used throughout the solution.
Points selected on load
A point is selected when the field loads if its id is in initialValue, or if the interactive-image-item sets style.isActive to true for that point. Points made active through style.isActive are written into the field's value on load, so the field's value includes both. For example, with initialValue: ['3','1'] and isActive set for point 4, the field's value is ["1","3","4"].
Examples and code snippets
Vehicle damage inspection example
The example shows a vehicle inspection form where the inspector taps the Damaged parts field and marks the damaged parts on the image of the vehicle. The field is required, so the form cannot be submitted until at least one part is selected. The groups property is used to differentiate between scratched and dented parts. On submit, the ids of the selected parts are saved with the inspection.
Single selection example
The example shows a field where only one part can be selected. isMultiple is set to false, so selecting a new point replaces the previous point, and the field's value is a single id instead of an array. The Primary damage group is limited to one point with maximumPoints. The field loads with the Door ('2') selected using initialValue, and the form stays untouched until the user changes the selection.
Pre-selected points with conditional visibility example
The example shows a follow-up inspection where parts recorded in the previous inspection are pre-selected. initialValue selects the Hood and Trunk, and the item's style.isActive selects the Roof ('4'), so the field's value on load is ["1","3","4"]. The field is shown only when the inspector indicates that the vehicle is damaged, and is disabled once the inspection is signed off. Each confirmed change in the picker increments a counter in solution state using onChange.
See also
Last updated
Was this helpful?