Skip to content

Commit

Permalink
fixes invalid relation in search form (#37137)
Browse files Browse the repository at this point in the history
* fixes invalid relation in search form

fixes #34410

* fetch the relation if only one is present
  • Loading branch information
3nids committed Jul 7, 2020
1 parent 961e6e8 commit 9eef5d7
Showing 1 changed file with 3 additions and 0 deletions.
Expand Up @@ -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();
Expand Down

0 comments on commit 9eef5d7

Please sign in to comment.