Problem/Motivation

Currently, the Views Reference Filter module does not support referencing entity IDs created via the Entity Construction Kit (ECK).
This limits the module's flexibility when working with custom entity types, as it's not possible to filter Views based on ECK entity references.

This functionality is especially useful in cases where content needs to be dynamically filtered by relationships to custom entities,
such as filtering nodes or users based on ECK-managed references.

Steps to reproduce

  1. Create a custom entity type using ECK.
  2. Create a View that displays content referencing the ECK entity.
  3. Attempt to add a Views Reference Filter based on the ECK entity ID.
  4. Observe that ECK entity IDs are not available or functional in the filter options.

Proposed resolution

  • Enhance the Views Reference Filter module to support filtering by entity IDs of ECK-based entities.
  • Ensure proper detection of ECK entity types within the Views integration.
  • Adjust filter logic to correctly handle references to ECK entity IDs.
  • Optionally, expose ECK entity types as selectable options in the Views UI for the reference filter configuration.

A patch implementing this functionality has already been developed and is attached to this issue.

Remaining tasks

  • Review and test the attached patch for compatibility and expected behavior.
  • Provide feedback or suggestions for improvements.
  • Commit the patch if approved.

User interface changes

  • If applicable, ECK entity types will appear as options when configuring Views Reference Filters.

API changes

  • No API changes are expected unless further integration with ECK's internal APIs becomes necessary.

Data model changes

  • None.

Comments

gerson.analista created an issue. See original summary.

gerson.analista’s picture

StatusFileSize
new2.13 KB

Patch attached

This issue includes an initial patch that implements support for filtering by ECK entity IDs in the Views Reference Filter module.

The patch provides the basic functionality but still requires thorough testing to ensure compatibility with various ECK setups and use cases. Feedback and improvements are welcome.

Please review and test as needed.

gerson.analista’s picture

Status: Active » Needs review
maximkashuba’s picture

Version: 2.0.0-beta5 » 2.0.x-dev
Status: Needs review » Fixed

Thanks for the report @gerson.analista.

In 2.0.0-beta5 hook_views_data_alter() resolved the target entity type from a hardcoded
list of columns: nid (node), uid (user), tid (taxonomy_term), gid (group), plus
product_id / variation_id for Commerce. Anything else — including an ECK entity's own ID
column — was skipped.

As of 2.0.0-beta6 that list is gone: the hook uses the Entity API
(EntityTypeManager::getDefinitions()) to map every content entity type's base/data table
and ID key, so the filter is exposed for any content entity, ECK included, with no
ECK-specific code.

Verified on Drupal 10.3 with eck 2.1.0: an ECK-based view can be filtered both by its own
ID and by an entity reference field, and the reference view options are built correctly.

Marking as fixed in 2.0.0-beta6; the patch in #2 is no longer needed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.