- Issue created by @mrjey
When a user adds a VERF filter for a custom entity base fields with cardinality (multiple values), the filter is not assigning the correct column name (field_target_id). It is taking something like "field_field" as column name.
1. Create a custom entity with a "entity_reference" base field and cardinality ulimited:
<?php
[...]
$fields['my_field'] = BaseFieldDefinition::create('entity_reference')
->setSetting('target_type', 'target_entity_id')
->setSetting('handler', 'default')
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
[...]
?>
2. Create a view for the created entity and add a VERF filter for the field "my_field"
The solution should be taking the column name from the schema when creating the filter definition:
<?php
[...]
$columns = $base_field_storage_definition->getColumns();
$column_name = isset($columns) ? array_key_first($columns) : $field_name;
$column_name = $table_mapping->getFieldColumnName($base_field_storage_definition, $column_name);
[...]
?>
Active
2.0
Code