I'd like to know how I can put a drop-down menu as an input in the graphical modeler of QGIS. This drop-down input should allow to choice among the values of the specific field of a layer or values from a csv file.
1 Answer
The only way I know so far is to use the Enum-Input as similarly described in this this answer.
The "Enum" input returns an integer for each list value, starting with 0. To link this resulting variable (e.g. @enum) with an input layer for example in the algorithm "Extract by expression" you can define the expression there like "matching_id" = @enum. By selecting a value from the drop down the algorithm's output is/are the matching records/features of the input layer.
Requirements are that:
- the layer or table whose values are to be selectable as drop down must have an (if applicable additionally) integer id starting with 0!
- the enum input must be defined manually with the values to be selected, in exact order of the matching ID!