The following code updates the value of the field ("name") in the console and shows the result but the actual attribute table does not get updated. Can anybody suggest the error in the code?
layer = iface.activeLayer()
selected_feature = layer.selectedFeatures()
layer.startEditing()
for feature in selected_feature:
feature["name"] = "Test name"
layer.commitChanges()