When I add a point in PyQGIS and then the object form opens, I want the attributes to be filled with given input or selection options. I want to prevent free text input. Without PyQGIS it is possible under Layer-Properties and attribute form with value mapping etc. See pic 1
In my case, my plugin loads a layer directly from the PostgreSQL database. Our users should not make changes in the layer properties. With this code I get the object form of the last object.:
layer = iface.activeLayer() features = layer.getFeatures() feature_list = list(f for f in features) feat = feature_list[-1] iface.openFeatureForm(layer, feat, True)
How can I access the attribute selection in openFeatureForm with PyQGIS?
For example, I want the "bezirk" column to have only two options.