@@ -77,9 +77,9 @@ QgsAttributeForm::QgsAttributeForm( QgsVectorLayer *vl, const QgsFeature &featur
77
77
connect ( vl, &QgsVectorLayer::beforeAddingExpressionField, this , &QgsAttributeForm::preventFeatureRefresh );
78
78
connect ( vl, &QgsVectorLayer::beforeRemovingExpressionField, this , &QgsAttributeForm::preventFeatureRefresh );
79
79
connect ( vl, &QgsVectorLayer::selectionChanged, this , &QgsAttributeForm::layerSelectionChanged );
80
+ connect ( this , &QgsAttributeForm::modeChanged, this , &QgsAttributeForm::updateContainersVisibility );
80
81
81
- // constraints management
82
- updateAllConstraints ();
82
+ updateContainersVisibility ();
83
83
}
84
84
85
85
QgsAttributeForm::~QgsAttributeForm ()
@@ -823,6 +823,7 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww )
823
823
synchronizeEnabledState ();
824
824
825
825
mExpressionContext .setFeature ( ft );
826
+
826
827
mExpressionContext << QgsExpressionContextUtils::formScope ( ft, modeString ( mMode ) );
827
828
828
829
// Recheck visibility for all containers which are controlled by this value
@@ -834,6 +835,22 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww )
834
835
}
835
836
}
836
837
838
+ void QgsAttributeForm::updateContainersVisibility ()
839
+ {
840
+
841
+ mExpressionContext << QgsExpressionContextUtils::formScope ( QgsFeature ( mFeature ), modeString ( mMode ) );
842
+
843
+ const QVector<ContainerInformation *> infos = mContainerVisibilityInformation ;
844
+
845
+ for ( ContainerInformation *info : infos )
846
+ {
847
+ info->apply ( &mExpressionContext );
848
+ }
849
+
850
+ // and update the constraints
851
+ updateAllConstraints ();
852
+ }
853
+
837
854
void QgsAttributeForm::updateConstraint ( const QgsFeature &ft, QgsEditorWidgetWrapper *eww )
838
855
{
839
856
QgsFieldConstraints::ConstraintOrigin constraintOrigin = mLayer ->isEditable () ? QgsFieldConstraints::ConstraintOriginNotSet : QgsFieldConstraints::ConstraintOriginLayer;
0 commit comments