You are here

function cck_select_other_field_formatter_view in CCK Select Other 7.2

Same name and namespace in other branches
  1. 7 cck_select_other.module \cck_select_other_field_formatter_view()

Implementation of hook_field_formatter_view().

File

./cck_select_other.module, line 48
Implements a select list widget that lets a user provide an alternate option.

Code

function cck_select_other_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  if ($display['type'] == 'cck_select_other') {

    // Only format for the cck_select_other display (just in case).
    $settings = $instance['widget']['settings'];
    $options = cck_select_other_options($instance);
    $element = array();
    foreach ($items as $delta => $item) {
      $value = isset($options[$item['value']]) ? field_filter_xss($options[$item['value']]) : field_filter_xss($item['value']);
      $element[$delta] = array(
        '#markup' => $value,
      );
    }
    return $element;
  }
}