Skip to content
Permalink
Browse files

Fix N:M Relations

  • Loading branch information
m-kuhn committed Sep 15, 2017
1 parent 5bd164b commit a0819053fdf0796d3ebad830cdddd82071e351a5
Showing with 4 additions and 6 deletions.
  1. +2 −2 src/app/qgsfieldsproperties.cpp
  2. +2 −4 src/gui/qgsattributeform.cpp
@@ -397,9 +397,9 @@ void QgsFieldsProperties::loadRelations()
if ( nmrel.fieldPairs().at( 0 ).referencingField() != relation.fieldPairs().at( 0 ).referencingField() )
nmCombo->addItem( QStringLiteral( "%1 (%2)" ).arg( nmrel.referencedLayer()->name(), nmrel.fieldPairs().at( 0 ).referencedField() ), nmrel.id() );

const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( mLayer, relation.id() );
const QgsEditFormConfig editFormConfig = mLayer->editFormConfig();

const QVariant nmrelcfg = setup.config().value( QStringLiteral( "nm-rel" ) );
const QVariant nmrelcfg = editFormConfig.widgetConfig( relation.id() ).value( QStringLiteral( "nm-rel" ) );

int idx = nmCombo->findData( nmrelcfg.toString() );

@@ -1594,8 +1594,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
const QgsAttributeEditorRelation *relDef = static_cast<const QgsAttributeEditorRelation *>( widgetDef );

QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper( mLayer, relDef->relation(), nullptr, this );
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, relDef->relation().id() );
rww->setConfig( widgetSetup.config() );
rww->setConfig( mLayer->editFormConfig().widgetConfig( relDef->relation().id() ) );
rww->setContext( context );
newWidgetInfo.widget = rww->widget();
rww->setShowLabel( relDef->showLabel() );
@@ -1757,8 +1756,7 @@ void QgsAttributeForm::createWrappers()
if ( relation.isValid() )
{
QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper( mLayer, relation, myWidget, this );
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, relation.id() );
rww->setConfig( widgetSetup.config() );
rww->setConfig( mLayer->editFormConfig().widgetConfig( relation.id() ) );
rww->setContext( mContext );
rww->widget(); // Will initialize the widget
mWidgets.append( rww );

0 comments on commit a081905

Please sign in to comment.
You can’t perform that action at this time.