diff --git a/src/gui/vector/qgsattributesformproperties.cpp b/src/gui/vector/qgsattributesformproperties.cpp index 8c4cf318c7d4..ec6b4e614d7a 100644 --- a/src/gui/vector/qgsattributesformproperties.cpp +++ b/src/gui/vector/qgsattributesformproperties.cpp @@ -793,6 +793,7 @@ QgsAttributeEditorElement *QgsAttributesFormProperties::createAttributeEditorWid case DnDTreeItemData::Relation: { const QgsRelation relation = QgsProject::instance()->relationManager()->relation( itemData.name() ); + QgsAttributeEditorRelation *relDef = new QgsAttributeEditorRelation( relation, parent ); const QgsAttributesFormProperties::RelationEditorConfiguration relationEditorConfig = itemData.relationEditorConfiguration(); relDef->setRelationWidgetTypeId( relationEditorConfig.mRelationWidgetType ); @@ -1157,6 +1158,16 @@ QTreeWidgetItem *QgsAttributesDnDTree::addItem( QTreeWidgetItem *parent, QgsAttr newItem->setText( 0, data.displayName() ); newItem->setIcon( 0, icon ); + if ( data.type() == QgsAttributesFormProperties::DnDTreeItemData::Relation ) + { + const QgsRelation relation = QgsProject::instance()->relationManager()->relation( data.name() ); + if ( !relation.isValid() || relation.referencedLayer() != mLayer ) + { + newItem->setText( 0, tr( "Invalid relation" ) ); + newItem->setForeground( 0, QColor( 255, 0, 0 ) ); + } + } + if ( index < 0 ) parent->addChild( newItem ); else