You are here

function fc_preprocess_field in Field Complete 7

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

See also

theme_field()

field.tpl.php

File

./fc.module, line 333
Field Complete - Provides field-based completeness for any entity.

Code

function fc_preprocess_field(&$variables) {
  $element = $variables['element'];
  $types = fc_enabled_entity_types();
  if (in_array($element['#entity_type'], $types)) {
    $instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
    $fc_extras = array();
    if (!empty($element['#formatter']) && $element['#formatter'] == 'editable') {
      $variables['classes_array'][] = drupal_html_class('field-formatter-' . $element['#formatter']);
      $variables['field_is_editable'] = TRUE;
      if (!empty($instance['settings']['fc']['fc_include'])) {
        $variables['classes_array'][] = 'field-complete';
        $variables['field_is_complete'] = TRUE;
        $fc_extras = array(
          '#theme' => 'form_complete_marker',
        );
      }
      if (!empty($instance['required'])) {
        $variables['classes_array'][] = 'field-required';
        $variables['field_is_required'] = TRUE;
        $fc_extras = array(
          '#theme' => 'form_required_marker',
        );
      }
    }
    $variables['fc_extras'] = $fc_extras;
  }
}