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