You are here

function pm_field_formatter_view in Drupal PM (Project Management) 7.2

Same name and namespace in other branches
  1. 8 pm.module \pm_field_formatter_view()
  2. 7.3 pm.module \pm_field_formatter_view()

Implements hook_field_formatter_view().

File

./pm.module, line 835
Main module file for the Project Management module.

Code

function pm_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  switch ($display['type']) {
    case 'pm_list_default':
      $allowed_values = list_allowed_values($field, $instance, $entity_type, $entity);
      foreach ($items as $delta => $item) {
        $value = '';
        if (isset($allowed_values[$item['value']])) {
          $value = field_filter_xss($allowed_values[$item['value']]);
        }
        else {

          // If no match was found in allowed values, fall back to the key.
          $value = field_filter_xss($item['value']);
        }
        $key = $item['value'];
        $output = theme('pm_list_default', array(
          'value' => $value,
          'key' => $key,
          'field_name' => $instance['field_name'],
        ));
        $element[$delta] = array(
          '#markup' => $output,
        );
      }
      break;
  }
  return $element;
}