Make field group label language more flexible

Created on 29 October 2015, about 9 years ago
Updated 1 June 2024, 7 months ago

Hello,

Issue:
When using entity translation, and you have a separate language for your content and your interface, the field group labels will stick to the interface language.

Solution:
Improve the way the field group labels are handled, and allow a custom language to be passed.

Attached you can find a patch which makes the above possible without breaking any normal behaviour.

Below you can find the example hook which will show how you can make a difference between content and interface field groups using a hook in your custom module.

/**
 * Implements hook_field_group_pre_render().
 *
 * Example call to make the label content language aware.
 */
function hook_field_group_pre_render(&$element, $group, &$form) {
  if ($group->entity_type == 'node' && !empty($group->label)) {
    if (isset($group->format_settings['instance_settings']['show_label']) && $group->format_settings['instance_settings']['show_label'] == 1) {
      // Set content field groups to a different language. This can be set to
      // for example $entity->language.
      $group->label_language = 'nl';
    }
  }
}
Feature request
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

🇧🇪Belgium harings_rob

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024