qgis / QGIS-Documentation

QGIS Documentation
https://docs.qgis.org/latest
476 stars 698 forks source link

[feature] Form context expressions in value relation widget #2637

Open QGIS-feature-tracker opened 6 years ago

QGIS-feature-tracker commented 6 years ago

Original commit: https://github.com/qgis/QGIS/commit/83328ae5962816bca5d6728c18a034357e346618 by elpaso

The value relation widget filter expression can now use two new functions/variables that have access to the current values and geometry of the form being edited.

This allows for dynamic filtering (drill-down) as explained in the crowdfunding page: https://north-road.com/drill-down-cascading-forms/

The new functions/variables are:

Function: get_current_form_field_value( 'FIELD_NAME' )

Variable: @current_form_geometry

ghtmtt commented 6 years ago

@elpaso I cannot find the get_current_form_field_value function in the editor, I just get current_value. Is it the same? Do you have a project with the data to share so we can better explain it in the manual?

BTW, great improvement!

Gustry commented 6 years ago

Did you watch the video tutorial on the link above? It's quite good. I will have a look later

elpaso commented 6 years ago

@ghtmtt sorry: I forgot to update the original PR document, we decided to shorten the names and we now have:

@current_feature @current_geometry current_value()

Here are the docs:

sVariableHelpTexts.insert( QStringLiteral( "current_geometry" ), QCoreApplication::translate( "current_geometry", "Represents the geometry of the feature currently being edited in the form or the table row. Can be used in a form/row context to filter the related features." ) );
   sVariableHelpTexts.insert( QStringLiteral( "current_feature" ), QCoreApplication::translate( "current_feature", "Represents the feature currently being edited in the form or the table row. Can be used in a form/row context to filter the related features." ) );

current_value( 'FIELD_NAME' )

Returns the current, unsaved value of a field in the form or table row currently being edited. This will differ from the feature's actual attribute values for features which are currently being edited or have not yet been added to a layer

HelpExample( tr( "current_value( 'FIELD_NAME' )" ), tr( "The current value of field 'FIELD_NAME'." ), tr( "") )
ghtmtt commented 6 years ago

@elpaso thanks for the info. I'll assign this issue to myself and maybe ping you when the doc is ready. Thanks again for this feature

vidarusny commented 1 year ago

I tested this function in version 3.30.2. This is an important change for me. thanks for the development. However, when consulting an entity, everything works perfectly. on the other hand, on the modification of several entities, the function does not read the current value of the form. image is this the expected operation?