Select to view content in your preferred language

How to update value of field in Editor Widget (4.x)

726
0
07-13-2021 10:35 AM
PhilLarkin1
Frequent Contributor

platform: Experience Builder Dev v1.4, Javascript API 4.19

I would like to update the value of a field in the Editor Widget. I have attempted to update featureFormViewModel.feature.attributes but this does not show up in the EditorWidget. I have attempted to refresh the layer of the view model without luck: 

 

 

editorWidget.viewModel.featureFormViewModel.layer.refresh()

 

 

 

I've not yet tried to use applyEdits on the feature layer. It seems I should be able to update the data before sending off with this function. 

Example:

 

 

const editorWidget = new Editor({view: view, container: container})

editorWidget.watch('viewModel.featureFormViewModel.feature', (newValue) => {
    newValue.attributes.site_city = "New City"
}

const attributes = editorWidget.viewModel.featureFormViewModel.getValues()
console.log(attributes) //Updated city name is not shown in the attributes

const attributes = editorWidget.viewModel.featureFormViewModel.feature.attributes
console.log(attributes) //Updated city name IS shown in the attributes

 

 

 

Tags (2)
0 Kudos
0 Replies