This field is irrelevant to these pseudo-entities and shouldn't need to be used at all.
Before: Creating a new SearchKit search for Individual includes Contact Type in the default columns.
After: Now it doesn't, and the field is completely hidden for all but the Contact entity.
}
$field = array_diff_key($field, $internalProps);
}
+ // Hide the 'contact_type' field from Individual,Organization,Household pseudo-entities
+ if (!$isInternal && $this->getEntityName() !== 'Contact' && CoreUtil::isContact($this->getEntityName())) {
+ $values = array_filter($values, function($field) {
+ return $field['name'] !== 'contact_type';
+ });
+ }
}
/**
if ($e->display['settings'] || $e->display['type'] !== 'autocomplete' || !CoreUtil::isContact($e->savedSearch['api_entity'])) {
return;
}
+ if ($e->savedSearch['api_entity'] === 'Contact') {
+ $contactTypeIcon = ['field' => 'contact_type:icon'];
+ }
+ else {
+ $contactTypeIcon = ['icon' => CoreUtil::getInfoItem($e->savedSearch['api_entity'], 'icon')];
+ }
$e->display['settings'] = [
'sort' => [
['sort_name', 'ASC'],
'key' => 'sort_name',
'icons' => [
['field' => 'contact_sub_type:icon'],
- ['field' => 'contact_type:icon'],
+ $contactTypeIcon,
],
],
[
use Civi\Api4\Address;
use Civi\Api4\Contact;
use Civi\Api4\Household;
+use Civi\Api4\Individual;
use Civi\Api4\Tag;
/**
$this->assertArrayHasKey('household_name', $householdFields);
}
+ public function testContactPseudoEntityGetFields(): void {
+ $individualFields = (array) Individual::getFields(FALSE)
+ ->execute()->indexBy('name');
+ $this->assertArrayNotHasKey('sic_code', $individualFields);
+ $this->assertArrayNotHasKey('contact_type', $individualFields);
+ $this->assertArrayHasKey('last_name', $individualFields);
+ $this->assertEquals('Individual', $individualFields['birth_date']['entity']);
+ $this->assertEquals('Individual', $individualFields['age_years']['entity']);
+ }
+
public function testGetOptionsAddress(): void {
$getFields = Address::getFields(FALSE)->addWhere('name', '=', 'state_province_id')->setLoadOptions(TRUE);
->execute()
->indexBy('name');
// Ensure table & column are returned
- $this->assertEquals('civicrm_contact', $fields['display_name']['table_name']);
+ $this->assertEquals('civicrm_contact', $fields['contact_type']['table_name']);
$this->assertEquals('display_name', $fields['display_name']['column_name']);
// Check suffixes