function field_display_label_preprocess_field in Field Display Label 8
Same name and namespace in other branches
- 7 field_display_label.module \field_display_label_preprocess_field()
Implements hook_preprocess_field().
File
- ./
field_display_label.module, line 54 - Main file for Field Display Label module.
Code
function field_display_label_preprocess_field(&$variables) {
$element = $variables['element'];
$entity = $element['#object'];
if (empty($entity)) {
return;
}
$field_definition = $entity
->getFieldDefinition($element['#field_name']);
if ($field_definition instanceof ThirdPartySettingsInterface) {
$definition = $field_definition
->getThirdPartySetting('field_display_label', 'display_label');
if (isset($definition) && !empty($definition)) {
$variables['label'] = $definition;
}
}
}