File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -230,7 +230,13 @@ void QgsRelationReferenceWidget::setForeignKey( const QVariant& value )
230
230
231
231
if ( mReadOnlySelector )
232
232
{
233
- mLineEdit ->setText ( f.attribute ( mFkeyFieldIdx ).toString () );
233
+ QgsExpression expr ( mReferencedLayer ->displayExpression () );
234
+ QString title = expr.evaluate ( &f ).toString ();
235
+ if ( expr.hasEvalError () )
236
+ {
237
+ title = f.attribute ( mFkeyFieldIdx ).toString ();
238
+ }
239
+ mLineEdit ->setText ( title );
234
240
mFeatureId = f.id ();
235
241
}
236
242
else
@@ -565,7 +571,13 @@ void QgsRelationReferenceWidget::featureIdentified( const QgsFeature& feature )
565
571
{
566
572
if ( mReadOnlySelector )
567
573
{
568
- mLineEdit ->setText ( feature.attribute ( mFkeyFieldIdx ).toString () );
574
+ QgsExpression expr ( mReferencedLayer ->displayExpression () );
575
+ QString title = expr.evaluate ( &feature ).toString ();
576
+ if ( expr.hasEvalError () )
577
+ {
578
+ title = feature.attribute ( mFkeyFieldIdx ).toString ();
579
+ }
580
+ mLineEdit ->setText ( title );
569
581
mForeignKey = feature.attribute ( mFkeyFieldIdx );
570
582
mFeatureId = feature.id ();
571
583
}
You can’t perform that action at this time.
0 commit comments