* Creating a new address requires at minimum a contact's ID and location type ID
* and other attributes (although optional) like street address, city, country etc.
*
+ * @ui_join_filters is_primary
+ *
* @searchable secondary
* @since 5.19
* @package Civi\Api4
foreach ($entities as $entity) {
foreach ($entity['ui_join_filters'] ?? [] as $fieldName) {
$field = civicrm_api4($entity['name'], 'getFields', [
- 'select' => ['options'],
+ 'select' => ['options', 'data_type'],
'where' => [['name', '=', $fieldName]],
'loadOptions' => ['name'],
])->first();
- $value = isset($field['options'][0]) ? json_encode($field['options'][0]['name']) : '';
+ $value = '';
+ if ($field['data_type'] === 'Boolean') {
+ $value = TRUE;
+ }
+ elseif (isset($field['options'][0])) {
+ $fieldName .= ':name';
+ $value = json_encode($field['options'][0]['name']);
+ }
$conditions[] = [
- $alias . '.' . $fieldName . ($value ? ':name' : ''),
+ $alias . '.' . $fieldName,
'=',
$value,
];