+ // Multi-record custom field groups (to-date only the contact entity supports these)
+ if (in_array('CustomValue', $entity['type'])) {
+ $targetEntity = $allowedEntities['Contact'];
+ // Join from Custom group to Contact (n-1)
+ $alias = $entity['name'] . '_Contact_entity_id';
+ $joins[$entity['name']][] = [
+ 'label' => $entity['title'] . ' ' . $targetEntity['title'],
+ 'description' => '',
+ 'entity' => 'Contact',
+ 'conditions' => self::getJoinConditions('entity_id', $alias . '.id'),
+ 'defaults' => self::getJoinDefaults($alias, $targetEntity),
+ 'alias' => $alias,
+ 'multi' => FALSE,
+ ];
+ // Join from Contact to Custom group (n-n)
+ $alias = 'Contact_' . $entity['name'] . '_entity_id';
+ $joins['Contact'][] = [
+ 'label' => $entity['title_plural'],
+ 'description' => '',
+ 'entity' => $entity['name'],
+ 'conditions' => self::getJoinConditions('id', $alias . '.entity_id'),
+ 'defaults' => self::getJoinDefaults($alias, $entity),
+ 'alias' => $alias,
+ 'multi' => TRUE,
+ ];
+ }
+ // Non-custom DAO entities
+ elseif (!empty($entity['dao'])) {