From d9a632b5dca36917575b69b6ed083cb598796d03 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 7 Jul 2020 19:02:48 +0000 Subject: [PATCH] fixes invalid relation in search form --- .../editorwidgets/qgsrelationreferencesearchwidgetwrapper.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/editorwidgets/qgsrelationreferencesearchwidgetwrapper.cpp b/src/gui/editorwidgets/qgsrelationreferencesearchwidgetwrapper.cpp index d2df062ceb61..38a755e64171 100644 --- a/src/gui/editorwidgets/qgsrelationreferencesearchwidgetwrapper.cpp +++ b/src/gui/editorwidgets/qgsrelationreferencesearchwidgetwrapper.cpp @@ -207,6 +207,9 @@ void QgsRelationReferenceSearchWidgetWrapper::initWidget( QWidget *editor ) } QgsRelation relation = QgsProject::instance()->relationManager()->relation( config( QStringLiteral( "Relation" ) ).toString() ); + // if no relation is given from the config, fetch one if there is only one available + if ( !relation.isValid() && !layer()->referencingRelations( mFieldIdx ).isEmpty() && layer()->referencingRelations( mFieldIdx ).count() == 1 ) + relation = layer()->referencingRelations( mFieldIdx )[0]; mWidget->setRelation( relation, false ); mWidget->showIndeterminateState();