Class: QgsValueRelationFieldFormatter¶
Field formatter for a value relation field.
A value relation field formatter looks up the values from features on another layer.
Class Hierarchy¶
Base classes¶
A field formatter helps to handle and display values for a field.  | 
Methods
Static Methods
Returns a list of attributes required by the form context expression  | 
|
Returns a list of variables required by the form context expression  | 
|
Check whether the feature has all values required by the expression, optionally checks for parentFeature  | 
|
Returns a list of attributes required by the parent form's form context expression  | 
|
Returns a list of variables required by the parent form's form context expression  | 
|
Check if the expression requires a form scope (i.e. if it uses fields or geometry of the currently edited feature).  | 
|
Check if the expression requires a parent form scope (i.e. if it uses fields or geometry of the parent form's currently edited feature).  | 
|
Returns the (possibly   | 
|
Utility to convert a list or a string representation of an (hstore style: {1,2...}) list in value to a string list  | 
- class qgis.core.QgsValueRelationFieldFormatter[source]¶
 Bases:
QgsFieldFormatter- __init__()
 Constructor for QgsValueRelationFieldFormatter.
- __init__(a0: QgsValueRelationFieldFormatter)
 - Parameters:
 
- class ValueRelationItem(key: Any, value: str | None, description: str | None = '', group: Any = None)¶
 Bases:
objectConstructor for ValueRelationItem
QgsValueRelationFieldFormatter.ValueRelationItem()
QgsValueRelationFieldFormatter.ValueRelationItem(a0: QgsValueRelationFieldFormatter.ValueRelationItem)
- description¶
 
- group¶
 Value used to regroup items during sorting (since QGIS 3.38)
- key¶
 
- value¶
 
- createCache(self, layer: QgsVectorLayer | None, fieldIndex: int, config: Dict[str, Any]) Any[source]¶
 - Parameters:
 layer (Optional[QgsVectorLayer])
fieldIndex (int)
config (Dict[str, Any])
- Return type:
 Any
- createCache(config: Dict[str, Any], formFeature: QgsFeature = QgsFeature(), parentFormFeature: QgsFeature = QgsFeature()) List[QgsValueRelationFieldFormatter.ValueRelationItem][source]
 Create a cache for a value relation field. This can be used to keep the value map in the local memory if doing multiple lookups in a loop.
- Parameters:
 config (Dict[str, Any]) – The widget configuration
formFeature (
QgsFeature= QgsFeature()) – The feature currently being edited with current attribute valuesparentFormFeature (
QgsFeature= QgsFeature()) – For embedded forms only, the feature currently being edited in the parent form with current attribute values
- Return type:
 - Returns:
 A kvp list of values for the widget
- static expressionFormAttributes(expression: str | None) Set[str]¶
 Returns a list of attributes required by the form context
expression- Parameters:
 expression (Optional[str]) – Form filter expression
- Return type:
 Set[str]
- Returns:
 list of attributes required by the expression
Added in version 3.2.
- static expressionFormVariables(expression: str | None) Set[str]¶
 Returns a list of variables required by the form context
expression- Parameters:
 expression (Optional[str]) – Form filter expression
- Return type:
 Set[str]
- Returns:
 list of variables required by the expression
Added in version 3.2.
- static expressionIsUsable(expression: str | None, feature: QgsFeature, parentFeature: QgsFeature = QgsFeature()) bool[source]¶
 Check whether the
featurehas all values required by theexpression, optionally checks forparentFeature- Return type:
 bool
- Returns:
 Trueif the expression can be used
Added in version 3.2.
- Parameters:
 expression (Optional[str])
feature (QgsFeature)
parentFeature (
QgsFeature= QgsFeature())
- static expressionParentFormAttributes(expression: str | None) Set[str]¶
 Returns a list of attributes required by the parent form’s form context
expression- Parameters:
 expression (Optional[str]) – Form filter expression
- Return type:
 Set[str]
- Returns:
 list of parent attributes required by the expression
Added in version 3.14.
- static expressionParentFormVariables(expression: str | None) Set[str]¶
 Returns a list of variables required by the parent form’s form context
expression- Parameters:
 expression (Optional[str]) – Form filter expression
- Return type:
 Set[str]
- Returns:
 list of parent variables required by the expression
Added in version 3.14.
- static expressionRequiresFormScope(expression: str | None) bool[source]¶
 Check if the
expressionrequires a form scope (i.e. if it uses fields or geometry of the currently edited feature).- Parameters:
 expression (Optional[str]) – The widget’s filter expression
- Return type:
 bool
- Returns:
 Trueif the expression requires a form scope
Added in version 3.2.
- static expressionRequiresParentFormScope(expression: str | None) bool[source]¶
 Check if the
expressionrequires a parent form scope (i.e. if it uses fields or geometry of the parent form’s currently edited feature).- Parameters:
 expression (Optional[str]) – The widget’s filter expression
- Return type:
 bool
- Returns:
 Trueif the expression requires a parent form scope
Added in version 3.14.
- static resolveLayer(config: Dict[str, Any], project: QgsProject | None) QgsVectorLayer | None[source]¶
 Returns the (possibly
None) layer from the widget’sconfigandprojectAdded in version 3.8.
- Parameters:
 config (Dict[str, Any])
project (Optional[QgsProject])
- Return type:
 Optional[QgsVectorLayer]