You are here

function _field_view_formatter_options in Views (for Drupal 7) 8.3

Same name and namespace in other branches
  1. 7.3 modules/field/views_handler_field_field.inc \_field_view_formatter_options()

Helper function: Return an array of formatter options for a field type.

Borrowed from field_ui.

1 call to _field_view_formatter_options()
Field::buildOptionsForm in lib/Views/field/Plugin/views/field/Field.php
Default options form that provides the label widget that all fields should have.

File

./views.module, line 2235
Primarily Drupal hooks and global API functions to manipulate views.

Code

function _field_view_formatter_options($field_type = NULL) {
  $options =& drupal_static(__FUNCTION__);
  if (!isset($options)) {
    $field_types = field_info_field_types();
    $options = array();
    foreach (field_info_formatter_types() as $name => $formatter) {
      foreach ($formatter['field_types'] as $formatter_field_type) {

        // Check that the field type exists.
        if (isset($field_types[$formatter_field_type])) {
          $options[$formatter_field_type][$name] = $formatter['label'];
        }
      }
    }
  }
  if ($field_type) {
    return !empty($options[$field_type]) ? $options[$field_type] : array();
  }
  return $options;
}