6

I have a point layer with the attribute/field:

  • kingdom

with a value map widget so I can choose the values: Tree or mammal.

And a second field:

  • Species (where I will register: Pine, Oak, Deer or Fox)

When I choose Tree, I want the available choices in Species value map to be Pine or Oak, not Deer and Fox.

Is this possible in a QField project?

enter image description here

0

1 Answer 1

11

You can do this with the widget Value Relation. The process is fully explained here.

Example:

Create a point layer with the fields:

  1. type, text data type
  2. subtype, text data type enter image description here

Create a table without geometry with the field:

  1. type, string

enter image description here

Create another geometryless table with the fields:

  1. subtype (string)
  2. fk (integer) enter image description here

Start editing and add the types you want to the first geometryless table. The fid column will be filled automatically.

Add the subtypes you want to the second geometryless table. In the fk column, match the fid's from the first table.

enter image description here Doubleclick the point layer - Attribute Forms. Click the type field, Set Widget type: Value Relation, Layer: Your first geometryless table, Value column: type enter image description here

Click the subtype field. Widget type: Value relation, Layer: second table, key column:fk, Value column: subtype, filter expression: "fk" = current_value( 'type') enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.