diff --git a/src/core/attributeformmodelbase.cpp b/src/core/attributeformmodelbase.cpp index ecff6430e0..8ba1ebcdfa 100644 --- a/src/core/attributeformmodelbase.cpp +++ b/src/core/attributeformmodelbase.cpp @@ -253,10 +253,6 @@ void AttributeFormModelBase::resetModel() void AttributeFormModelBase::applyFeatureModel() { mExpressionContext = mFeatureModel->createExpressionContext(); - if ( mFeatureModel->linkedParentFeature().isValid() ) - { - mExpressionContext << QgsExpressionContextUtils::parentFormScope( mFeatureModel->linkedParentFeature() ); - } mExpressionContext << QgsExpressionContextUtils::formScope( mFeatureModel->feature() ); for ( int i = 0; i < invisibleRootItem()->rowCount(); ++i ) diff --git a/src/core/featuremodel.cpp b/src/core/featuremodel.cpp index c3e9189313..eb91944c37 100644 --- a/src/core/featuremodel.cpp +++ b/src/core/featuremodel.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -470,6 +471,11 @@ QgsExpressionContext FeatureModel::createExpressionContext() const } expressionContext << ExpressionContextUtils::cloudUserScope( mCloudUserInformation ); + if ( mLinkedParentFeature.isValid() ) + { + expressionContext << QgsExpressionContextUtils::parentFormScope( mLinkedParentFeature ); + } + return expressionContext; }