You are here

function colectomy_preprocess_field in Colectomy 7

Theme preprocess function for theme_field() and field.tpl.php.

A modified version of the field_preprocess_field() function which allows us to add some custom variables used later on the rendering of the array.

See also

theme_field()

field.tpl.php

File

./colectomy.module, line 37
Allows the option to hide the colon on field labels in field forms.

Code

function colectomy_preprocess_field(&$variables, $hook) {
  $element = $variables['element'];
  $variables['label_hidden'] = $element['#label_display'] == 'hidden';
  $variables['label'] = $variables['label_hidden'] ? NULL : check_plain($element['#title']);
  $variables['label_colon'] = $element['#label_display'] == 'inlinec' || $element['#label_display'] == 'abovec';
  if ($element['#label_display'] == 'inline' || $element['#label_display'] == 'inlinec') {
    $variables['classes_array'][] = 'clearfix';
  }
  if ($element['#label_display'] == 'inlinec') {
    $variables['classes_array']['field-label-inline'] = 'field-label-inline';
  }
  if ($variables['label_colon']) {
    $variables['theme_hook_suggestions'][] = 'colectomy_field';
  }
}