QGIS forms: How to limit available values in a dropdown field according to value sele

المشرف العام

Administrator
طاقم الإدارة
I'm building a rather complex entry form for the layer stored in a PostGIS database. I have a following usage scenario:

On several occasions i have dropdown fields which let user select a type of artefact (populated trough value relationto another table in a database), followed imediatly with the field letting them select a subtype (also populated trough value relation to another table in a database). I would like a choice of subtypes in the dropdown to be limited by the previous selection of a type.

In example, if i select type "ceramics" i would like the subtype dropdown to be limited only to options with a key value from 1 to 10, If i select type "metals" i would like the subtype dropdown to be limited only to options with a key value from 11 to 20, And so on.

I feel relatively fluent in SQL and qgis expression builder, and i would guess this could be achieved trough filter expression option on value relation widget, but i wouldnt know how to invoke the values from a form which is currently being filled.

I suspect some python code is needed - i'm not fluent in python but i guess i could adapt an example of code to my needs by renaming the fields etc.

Question is similar to Field Value Mapping QGIS but the answers there didnt point me out in directions i could apply with my current knowledge.

Much obliged,



أكثر...
 
أعلى