Add Views data automatically

Created on 22 June 2021, over 3 years ago
Updated 6 March 2024, 10 months ago

Problem/Motivation

It would be handy to expose the computed fields to Views, to be able to be used in Views the same as with regular fields.

Proposed resolution

Attached patch adds a hook_views_data_alter() and loops over plugins to add field data.

NB Requires core patch at https://www.drupal.org/project/drupal/issues/2981047 πŸ“Œ Allow adding computed bundle fields in Views Fixed

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada bgilhome Victoria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡±Netherlands Jan-E
  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡¦Ukraine HitchShock Ukraine

    It doesn't work for users because:
    Entity type - user
    Base field - users

    Patch #1 Updated the first patch to fix the issue with users according to the core behavior (see EntityViewsData::getViewsData())

    Patch #5 is a great example of how to add a filter for a computed field, but one type of field is not enough to say that the issue is resolved.
    Also, I'm sure that it's not required for the current ticket. We can create a separate one for filters and sorts, where we will provide more cases, for more field types. But at the moment, it makes no sense to block the task because of this.

Production build 0.71.5 2024