Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern::isFieldVisible returns false on valid mappings by using field instead of id #338

Open
wants to merge 4 commits into
base: 8.x-1.x
Choose a base branch
from

Conversation

pvbergen
Copy link

Drupal\ui_patterns_views\Plugin\views\row\Pattern::isFieldVisible returns false on valid mappings. This is caused by using different identifiers for mapping and visiblity check.

Problem

  • ViewsRowSource::getSourceField uses DisplayHandlerBase::getFieldLabels, returning field labels keyes by id
  • Pattern::isFieldVisible passes FieldPluginBase::field to hasMappingDestination, meaning field name

These values are usually the same in views, but don't have to be. This can cause fields to not be passed to patterns.

How to reproduce

We had this bug with the field "Published on" provided by drupal/publication_date.

  1. Install ui_patterns_view and publication_date
  2. Create a view, inserting the field "Published on" twice or more.
  3. Check the view config: It will show different values for id and field on all but the first field plugin

Sample from a view config

fields:
published_at:
id: published_at
table: node_field_data
field: published_at
published_at_1:
id: published_at_1
table: node_field_data
field: published_at
published_at_2:
id: published_at_2
table: node_field_data
field: published_at

Solution

Pass field id to isFieldVisible along with field. See changes in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant