function farm_flags_preprocess_field in farmOS 7
Implements hook_preprocess_field().
File
- modules/
farm/ farm_flags/ farm_flags.module, line 67 - Farm flags module.
Code
function farm_flags_preprocess_field(&$variables, $hook) {
// Only act on field_farm_flags.
if (empty($variables['element']['#field_name']) || $variables['element']['#field_name'] != 'field_farm_flags') {
return;
}
// Wrap the flag in a span with a class.
if (!empty($variables['element']['#items'])) {
foreach ($variables['element']['#items'] as $key => $item) {
if (!empty($variables['items'][$key]['#markup'])) {
$string = $variables['items'][$key]['#markup'];
$class = $item['value'];
$variables['items'][$key]['#markup'] = farm_flags_wrap($string, $class);
}
}
}
}