@@ -1039,6 +1039,16 @@ QList<QgsEditorWidgetWrapper *> QgsAttributeForm::constraintDependencies( QgsEdi
1039
1039
return wDeps;
1040
1040
}
1041
1041
1042
+ QgsRelationWidgetWrapper *QgsAttributeForm::setupRelationWidgetWrapper ( const QgsRelation &rel, const QgsAttributeEditorContext &context )
1043
+ {
1044
+ QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper ( mLayer , rel, nullptr , this );
1045
+ const QVariantMap config = mLayer ->editFormConfig ().widgetConfig ( rel.id () );
1046
+ rww->setConfig ( config );
1047
+ rww->setContext ( context );
1048
+
1049
+ return rww;
1050
+ }
1051
+
1042
1052
void QgsAttributeForm::preventFeatureRefresh ()
1043
1053
{
1044
1054
mPreventFeatureRefresh = true ;
@@ -1375,10 +1385,7 @@ void QgsAttributeForm::init()
1375
1385
1376
1386
Q_FOREACH ( const QgsRelation &rel, QgsProject::instance ()->relationManager ()->referencedRelations ( mLayer ) )
1377
1387
{
1378
- QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper ( mLayer , rel, nullptr , this );
1379
- const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry ()->findBest ( mLayer , rel.id () );
1380
- rww->setConfig ( setup.config () );
1381
- rww->setContext ( mContext );
1388
+ QgsRelationWidgetWrapper *rww = setupRelationWidgetWrapper ( rel, mContext );
1382
1389
1383
1390
QgsAttributeFormRelationEditorWidget *formWidget = new QgsAttributeFormRelationEditorWidget ( rww, this );
1384
1391
formWidget->createSearchWidgetWrappers ( mContext );
@@ -1676,9 +1683,8 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
1676
1683
{
1677
1684
const QgsAttributeEditorRelation *relDef = static_cast <const QgsAttributeEditorRelation *>( widgetDef );
1678
1685
1679
- QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper ( mLayer , relDef->relation (), nullptr , this );
1680
- rww->setConfig ( mLayer ->editFormConfig ().widgetConfig ( relDef->relation ().id () ) );
1681
- rww->setContext ( context );
1686
+ QgsRelationWidgetWrapper *rww = setupRelationWidgetWrapper ( relDef->relation (), context );
1687
+
1682
1688
rww->setShowLabel ( relDef->showLabel () );
1683
1689
rww->setShowLinkButton ( relDef->showLinkButton () );
1684
1690
rww->setShowUnlinkButton ( relDef->showUnlinkButton () );
0 commit comments