Skip to content

Instantly share code, notes, and snippets.

@colemanw
Last active February 21, 2019 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colemanw/a6621c4b08017f5d0e509830f2173667 to your computer and use it in GitHub Desktop.
Save colemanw/a6621c4b08017f5d0e509830f2173667 to your computer and use it in GitHub Desktop.
Add tag fields for multiple entities
diff --git a/includes/utils.inc b/includes/utils.inc
index dc502c5..97757dc 100644
--- a/includes/utils.inc
+++ b/includes/utils.inc
@@ -806,16 +806,6 @@ function wf_crm_get_fields($var = 'fields') {
'table' => 'group',
'expose_list' => TRUE,
);
- $tagsets = array('' => t('Tag(s)')) + CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
- foreach ($tagsets as $pid => $name) {
- $fields['other_tag' . ($pid ? "_$pid" : '')] = array(
- 'name' => $name,
- 'type' => 'select',
- 'extra' => array('multiple' => 1, 'civicrm_live_options' => 1),
- 'table' => 'tag',
- 'expose_list' => TRUE,
- );
- }
$fields['activity_activity_type_id'] = array(
'name' => t('Activity # Type'),
'type' => 'select',
@@ -887,7 +877,9 @@ function wf_crm_get_fields($var = 'fields') {
'integer' => 1,
),
);
+ $tag_entities = array('other', 'activity');
if (isset($sets['case'])) {
+ $tag_entities[] = 'case';
$case_info = new CRM_Case_XMLProcessor_Process();
$fields['case_case_type_id'] = array(
'name' => t('Case # Type'),
@@ -968,6 +960,18 @@ function wf_crm_get_fields($var = 'fields') {
}
}
}
+ $tagsets = array('' => t('Tag(s)')) + CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
+ foreach ($tagsets as $pid => $name) {
+ foreach ($tag_entities as $entity) {
+ $fields[$entity . '_tag' . ($pid ? "_$pid" : '')] = array(
+ 'name' => $name,
+ 'type' => 'select',
+ 'extra' => array('multiple' => 1, 'civicrm_live_options' => 1),
+ 'table' => 'tag',
+ 'expose_list' => TRUE,
+ );
+ }
+ }
$fields['relationship_relationship_type_id'] = array(
'name' => t('Relationship Type(s)'),
'type' => 'select',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment