Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter expression not working for Value Relation widget in 2024.1.0 #3429

Closed
raherin opened this issue May 14, 2024 · 3 comments
Closed

Filter expression not working for Value Relation widget in 2024.1.0 #3429

raherin opened this issue May 14, 2024 · 3 comments
Assignees
Milestone

Comments

@raherin
Copy link

raherin commented May 14, 2024

When using a filter expression on a value relations widget, the app will add all values that meet the filter expression when only one value is selected in the drop-down menu while filling out the form. This can be reproduced in the example project support/form_setup.

To reproduce the issue:

  1. Have a survey layer with a Value Relation widget and set a filter expression based on the value of another field:
image
  1. The expected behaviour, which is reproduced in QGIS, is that when selecting a plant type in the form, you will be able to select a plant of that type in the form. In this case, 'Vegetable' was selected as the plant type and 'Carrot' as the plant species:
image
  1. When filling out the form in the app, all of the species are saved to the field in the form. See video below:
Screen_Recording_20240514_164208.mp4
@tomasMizera tomasMizera added this to the 2024.2.0 milestone May 16, 2024
@uclaros
Copy link
Contributor

uclaros commented May 16, 2024

This weird behavior is actually caused by the project not being set up properly:

While the value relation for field type is properly set:

  • Key column is Code, -> stores values [A, B, C ...]
  • Value column is Description, -> displays values [Fruit, Vegetable, Flower ...]

The value relation for sub-type is wrong:

  • filter expression is OK, only shows entries where Code matches the type's selected Key.
  • Value column is Species, -> displays values [Carrot, apple ...]
  • ❌ Key column is Class, -> stores values [A, B, C ...] which do not correspond to a single Value entry

Setting the Key column to either fid or Species solves it, as there is now a 1-1 connection to the Value values.

So the question is: what should be displayed when the selected Key corresponds to multiple Values, and should we somehow warn users about it?
QGIS handles it by displaying the first matching value.
I believe our approach is more correct, we display a concatenated string of all corresponding values.

@wonder-sk
Copy link
Contributor

Note: there is a ticket for the plugin to detect such problems: MerginMaps/qgis-plugin#317

@tomasMizera
Copy link
Collaborator

Ping @raherin

@tomasMizera tomasMizera closed this as not planned Won't fix, can't repro, duplicate, stale May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants