3

There is the Preferred language field in Communication Preferences which allows to choose the contact's preferred language.

However when I try to create custom fields for a contact's second, third language, I don't find Language as a choice among the other Data and Input Field Types What would be the recommended way to make the language select like in Preferred language available for re-use in custom fields?

With all the languages in a select field defined and available somewhere, what I try to avoid here is that I need to re-enter all these languages by hand for my custom fields.

3

In CiviCRM, custom fields have the ability to re-use options from another custom field, but not from a core field like Preferred Language. So this is not currently possible via the UI.

2 Solutions come to mind, both using small amounts of custom code:

  1. Write a short script that uses the api to fetch all languages and then copy them into the options of one of your custom fields. Then re-use those same options in 3rd, 4th language fields.

  2. Write a tiny extension that implements hook_civicrm_customFieldOptions and populates those options dynamically by outputting the languages in the system.

2

My solution for this was to

  1. Setup Field with Alphanumeric and Select Properties, assigning it to any existing option set.
  2. Directly in the Database: Find Table: "civicrm_option_group" In that table find the option group you are trying to use (e.e: Languages). Take note of that row's "id".
  3. Directly in the Database: Find Table: "civicrm_custom_field" In that field find the field you created in Step 1.
  4. In the row of that field, edit the column: "option_group_id" to the id number you notated in Step 2.

This worked for me when trying to use the Languages list.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.