Skip to content
Permalink
Browse files

Field formatter: pass default value to the formatter

... even when it's equal to the default.
  • Loading branch information
elpaso committed Jan 31, 2020
1 parent 83e384a commit 092894b6a95e8492c329bd402dbfd0783b89b1d8
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/core/qgsfieldformatter.cpp
@@ -30,13 +30,13 @@ QString QgsFieldFormatter::representValue( QgsVectorLayer *layer, int fieldIndex
if ( layer->fields().fieldOrigin( fieldIndex ) == QgsFields::OriginProvider && layer->dataProvider() )
defVal = layer->dataProvider()->defaultValueClause( layer->fields().fieldOriginIndex( fieldIndex ) );

if ( layer->fields().exists( fieldIndex ) && ( defVal.isNull() || defVal != value ) )
if ( ! layer->fields().exists( fieldIndex ) )
{
return layer->fields().at( fieldIndex ).displayString( value );
return defVal;
}
else
{
return defVal;
return layer->fields().at( fieldIndex ).displayString( value.isNull() ? defVal : value );
}
}

0 comments on commit 092894b

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