Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Virtual fields are not editable
  • Loading branch information
domi4484 authored and github-actions[bot] committed Nov 11, 2021
1 parent 1d00168 commit 3b2a70a
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -594,24 +594,12 @@ void QgsAttributeForm::updateValuesDependenciesVirtualFields( const int originId

for ( int i = 0; i < dstVars.count(); i++ )
{
if ( !qgsVariantEqual( dstVars[i], srcVars[i] ) && srcVars[i].isValid() && fieldIsEditable( fieldIndexes[i] ) )
if ( !qgsVariantEqual( dstVars[i], srcVars[i] ) && srcVars[i].isValid() )
featureAttributes[fieldIndexes[i]] = srcVars[i];
}
}
updatedFeature.setAttributes( featureAttributes );

// If originIdx is a virtual field make sure it is up to date
{
QString expressionField = mLayer->expressionField( originIdx );
if ( ! expressionField.isEmpty() )
{
QgsExpressionContext context = createExpressionContext( updatedFeature );
QgsExpression exp( expressionField );
QVariant value = exp.evaluate( &context );
updatedFeature.setAttribute( originIdx, value );
}
}

// go through depending fields and update the virtual field with its expression
QList<QgsWidgetWrapper *> relevantWidgets = mVirtualFieldsDependencies.values( originIdx );
for ( QgsWidgetWrapper *ww : std::as_const( relevantWidgets ) )
Expand Down

0 comments on commit 3b2a70a

Please sign in to comment.