Still hot from our forge: a new QGIS plugin allows dynamic filtering of items in combo boxes in attribute forms.
This is a core-enhancement QGIS plugin that makes the implementation of complex dynamic filters in QGIS attribute forms an easy task. For example, this widget can be used to implement drill-down forms, where the values available in one field depend on the values of other fields.
The new “Form Value Relation” widget is essentially a clone of the core “Value Relation” widget with some important differences:
When the widget is created:
- the whole unfiltered features of the related layer are loaded and cached
- the form values of all the attributes are added to the context (see below)
- the filtering against the expression happens every time the widget is refreshed
- a signal is bound to the form changes and if the changed field is present in
the filter expression, the features are filtered against the expression and
the widget is refreshed
Using form values in the expression
A new expression function is available (in the “Custom” section):
This function returns the current value of a field in the editor form.
- This function can only be used inside forms and it’s particularly useful when used together with the custom widget `Form Value Relation`
- If the field does not exists the function returns an empty string.
Download the example project.
This is the new widget in action: changing the field FK_PROV, the ISTAT values are filtered according to the filter expression.