2

I have a custom field of an individual that stores the ID of a group (as int). I would like to change the display of the field to show the actual name of the group instead of the ID (same as contact reference functionality).

At the very least I would like to have this done on the contact summary page.

I have tried hook_civicrm_alterContent, but I am unsure how to change the actual displayed field value.

NOTE: I am able to get it to work by adding some javascript to the hook using jQuery to alter the value. This seems very hacked and getting the proper field is difficult because Civi does not sent distinct ids or classes for the fields being displayed. Something as simple as changing the display order of the fields would break it.

  • In what context do you want to show it? (e.g. in the admin interface?). – Alan Dixon Oct 17 '17 at 17:30
  • In this case when a user is viewing a contact's summary page. – Sleewok Oct 17 '17 at 20:27
  • I think you would have to create a new custom field type, you could model it on the contact reference field and call it group reference field. – Alan Dixon Oct 18 '17 at 21:42
  • Do you have a link to any documentation on how to do this? Google is not helpful :). – Sleewok Oct 24 '17 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.