Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions app/attributes/attributecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,16 @@ void AttributeController::prefillRelationReferenceField()
const QList<QgsRelation::FieldPair> fieldPairs = mLinkedRelation.fieldPairs();
for ( const QgsRelation::FieldPair &fieldPair : fieldPairs )
{
QMap<QUuid, std::shared_ptr<FormItem>>::iterator formItemsIterator = mFormItems.begin();
while ( formItemsIterator != mFormItems.end() )
QVariant foreignKey = mParentController->featureLayerPair().feature().attribute( fieldPair.referencedField() );
QString referencingField = fieldPair.referencingField();
QgsVectorLayer *childLayer = mLinkedRelation.referencingLayer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QgsVectorLayer *childLayer = mLinkedRelation.referencingLayer();
const QgsVectorLayer *childLayer = mLinkedRelation.referencingLayer();

if ( childLayer )
{
std::shared_ptr<FormItem> itemData = formItemsIterator.value();
if ( itemData->field().name() == fieldPair.referencingField() )
int fieldIndex = childLayer->fields().lookupField( referencingField );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int fieldIndex = childLayer->fields().lookupField( referencingField );
const int fieldIndex = childLayer->fields().lookupField( referencingField );

if ( fieldIndex != -1 )
{
QVariant fk = mParentController->featureLayerPair().feature().attribute( fieldPair.referencedField() );
setFormValue( itemData->id(), fk );
break;
mFeatureLayerPair.featureRef().setAttribute( fieldIndex, foreignKey );
}
++formItemsIterator;
}
}
}
Expand Down
Loading