function field_label_plurals_preprocess_field in Field label plurals 8
Same name and namespace in other branches
- 7 field_label_plurals.module \field_label_plurals_preprocess_field()
Implements hook_preprocess_field().
File
- ./
field_label_plurals.module, line 8
Code
function field_label_plurals_preprocess_field(&$variables) {
if (isset($variables['element']['#items']) && method_exists($variables['element']['#items'], 'count') && $variables['element']['#items']
->count() > 1) {
$data = $variables['element']['#items']
->getDataDefinition();
$plural = $data
->getThirdPartySetting('field_label_plurals', 'label_plural');
if ($plural) {
$variables['label'] = $plural;
}
}
}