@@ -1040,6 +1040,16 @@ QList<QgsEditorWidgetWrapper *> QgsAttributeForm::constraintDependencies( QgsEdi
10401040 return wDeps;
10411041}
10421042
1043+ QgsRelationWidgetWrapper *QgsAttributeForm::setupRelationWidgetWrapper ( const QgsRelation &rel, const QgsAttributeEditorContext &context )
1044+ {
1045+ QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper ( mLayer , rel, nullptr , this );
1046+ const QVariantMap config = mLayer ->editFormConfig ().widgetConfig ( rel.id () );
1047+ rww->setConfig ( config );
1048+ rww->setContext ( context );
1049+
1050+ return rww;
1051+ }
1052+
10431053void QgsAttributeForm::preventFeatureRefresh ()
10441054{
10451055 mPreventFeatureRefresh = true ;
@@ -1377,10 +1387,7 @@ void QgsAttributeForm::init()
13771387 const QList<QgsRelation> relations = QgsProject::instance ()->relationManager ()->referencedRelations ( mLayer );
13781388 for ( const QgsRelation &rel : relations )
13791389 {
1380- QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper ( mLayer , rel, nullptr , this );
1381- const QVariantMap config = mLayer ->editFormConfig ().widgetConfig ( rel.id () );
1382- rww->setConfig ( config );
1383- rww->setContext ( mContext );
1390+ QgsRelationWidgetWrapper *rww = setupRelationWidgetWrapper ( rel, mContext );
13841391
13851392 QgsAttributeFormRelationEditorWidget *formWidget = new QgsAttributeFormRelationEditorWidget ( rww, this );
13861393 formWidget->createSearchWidgetWrappers ( mContext );
@@ -1678,9 +1685,8 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
16781685 {
16791686 const QgsAttributeEditorRelation *relDef = static_cast <const QgsAttributeEditorRelation *>( widgetDef );
16801687
1681- QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper ( mLayer , relDef->relation (), nullptr , this );
1682- rww->setConfig ( mLayer ->editFormConfig ().widgetConfig ( relDef->relation ().id () ) );
1683- rww->setContext ( context );
1688+ QgsRelationWidgetWrapper *rww = setupRelationWidgetWrapper ( relDef->relation (), context );
1689+
16841690 rww->setShowLabel ( relDef->showLabel () );
16851691 rww->setShowLinkButton ( relDef->showLinkButton () );
16861692 rww->setShowUnlinkButton ( relDef->showUnlinkButton () );
0 commit comments