You are here

function redhen_fields_field_formatter_view in RedHen CRM 7

Implements hook_field_formatter_view().

File

modules/redhen_fields/redhen_fields.module, line 425
Defines email, phone and address field types for RedHen CRM.

Code

function redhen_fields_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  switch ($display['type']) {
    case 'redhen_email_formatter':
      $element['#theme'] = 'field__redhen_fields_email_formatter';
      foreach ($items as $delta => $item) {
        $output = theme('redhen_fields_email_formatter_row', array(
          'item' => $item,
          'delta' => $delta,
        ));
        $element[$delta] = array(
          '#markup' => $output,
        );
      }
      $element['#attached']['css'] = array(
        drupal_get_path('module', 'redhen_fields') . '/redhen_fields.css',
      );
      break;
    case 'redhen_email_primary':
      foreach ($items as $delta => $item) {
        if (!empty($item['default'])) {
          $element[$delta] = array(
            '#markup' => l($item['value'], 'mailto:' . $item['value']),
          );
          break;
        }
      }
      break;
  }
  return $element;
}