Summary
Value Relation fields with a FilterExpression (e.g. "category" = 'drain_type' on a lookup table that stores multiple pick-lists sharing key values across categories) show the correct filtered list in the picker drawer, but the collapsed field can display the label from the wrong category when a key value collides across categories.
Example
Field "Drain Type", key value_int = 0, filter "category" = 'drain_type'. Drawer correctly shows/highlights "unknown". Collapsed field shows "accessible" instead - the label for value_int = 0 under a different category.
Root cause
Two code paths resolve Value Relation data; only one applies FilterExpression:
ValueRelationFeaturesModel (drawer/picker list) - applies the filter. Correct.
ValueRelationController::lookupDisplayTextOnValueChanged() in app/valuerelationcontroller.cpp (collapsed-field text, used on initial load and every value change) - queries key IN (...) against the whole lookup table with no filter and no ordering, so a key that exists under multiple categories can resolve to the wrong row.
The sibling method lookupDisplayTextOnHotreload() (used for cascading fields) already applies the filter correctly - it's only the plain value-changed path that's missing it.
Fix
Pass the current feature and apply the configured filter in lookupDisplayTextOnValueChanged(), same as lookupDisplayTextOnHotreload() already does:
app/valuerelationcontroller.h / .cpp - add a feature parameter to lookupDisplayTextOnValueChanged() and pass useFilterExpression = !mFilterExpression.isEmpty() into lookupDisplayTextAsync().
app/qml/form/editors/MMFormValueRelationEditor.qml - pass root._fieldController.featureLayerPair.feature at the lookupDisplayTextOnValueChanged() call site.
Behavior change
If a stored key no longer satisfies its FilterExpression, the collapsed field will now clear/invalidate the selection instead of showing the raw key as fallback text (matches existing hot-reload behavior). Fields without a FilterExpression are unaffected.
Test coverage
Extend TestFormEditors::testValueRelationControllerLookup in app/test/testformeditors.cpp with a lookup key that collides across two filter partitions, asserting the label resolved matches the active filter/form context, not the first unfiltered row.
Summary
Value Relation fields with a
FilterExpression(e.g."category" = 'drain_type'on a lookup table that stores multiple pick-lists sharing key values across categories) show the correct filtered list in the picker drawer, but the collapsed field can display the label from the wrong category when a key value collides across categories.Example
Field "Drain Type", key
value_int = 0, filter"category" = 'drain_type'. Drawer correctly shows/highlights "unknown". Collapsed field shows "accessible" instead - the label forvalue_int = 0under a differentcategory.Root cause
Two code paths resolve Value Relation data; only one applies
FilterExpression:ValueRelationFeaturesModel(drawer/picker list) - applies the filter. Correct.ValueRelationController::lookupDisplayTextOnValueChanged()inapp/valuerelationcontroller.cpp(collapsed-field text, used on initial load and every value change) - querieskey IN (...)against the whole lookup table with no filter and no ordering, so a key that exists under multiple categories can resolve to the wrong row.The sibling method
lookupDisplayTextOnHotreload()(used for cascading fields) already applies the filter correctly - it's only the plain value-changed path that's missing it.Fix
Pass the current feature and apply the configured filter in
lookupDisplayTextOnValueChanged(), same aslookupDisplayTextOnHotreload()already does:app/valuerelationcontroller.h/.cpp- add afeatureparameter tolookupDisplayTextOnValueChanged()and passuseFilterExpression = !mFilterExpression.isEmpty()intolookupDisplayTextAsync().app/qml/form/editors/MMFormValueRelationEditor.qml- passroot._fieldController.featureLayerPair.featureat thelookupDisplayTextOnValueChanged()call site.Behavior change
If a stored key no longer satisfies its
FilterExpression, the collapsed field will now clear/invalidate the selection instead of showing the raw key as fallback text (matches existing hot-reload behavior). Fields without aFilterExpressionare unaffected.Test coverage
Extend
TestFormEditors::testValueRelationControllerLookupinapp/test/testformeditors.cppwith a lookup key that collides across two filter partitions, asserting the label resolved matches the active filter/form context, not the first unfiltered row.