- Issue created by @mindaugasd
- π±πΉLithuania mindaugasd
What I found so far:
datafield.views.inc
has these lines at the top:
$field_name = $field_storage->getName(); $columns = $field_storage->getSetting('columns'); $field_settings = $field_storage->getSetting('field_settings');
$columns is filled, but $field_settings is empty.
- π±πΉLithuania mindaugasd
Fixed one bug for now, but don't work yet.
Replaced
$field_settings = $field_storage->getSetting('field_settings');
with
$field_configs = \Drupal::entityTypeManager() ->getStorage('field_config') ->loadByProperties([ 'field_name' => $field_name, 'entity_type' => $field_storage->getTargetEntityTypeId(), ]); $field_config = reset($field_configs); $field_settings = $field_config ? $field_config->getSetting('field_settings') : [];
Based on the type of bug, it means this feature was not tested yet.
- π±πΉLithuania mindaugasd
The rest of code AI fixed. I don't know what it did, but it rewrote a lot of code and now it works. I attached the patch for version 2.0.11.
This is what it said:
β’ Correct variable $target_entity_type_id is used instead of the wrong $field_settings['target_type'].
β’ Added failsafes so the hook does nothing if no instance exists or if the referenced entity type is missing.// TODO:
β’ If you have the same field storage reused by several bundles and the sub-field βentity_reference_typeβ differs between instances, you might want to iterate over all $field_configs and create one relationship per encountered target entity type. - π±πΉLithuania mindaugasd
Updated patch to fix notice:
Notice: Only variables should be passed by reference in datafield_field_views_data() (line 61
- 7d91dc09 committed on 2.x
Issue #3540021: Views relationships dont work on reference field
- 7d91dc09 committed on 2.x