function list_allowed_values

cis7 list.module list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL)
cle7 list.module list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL)
elmsmedia7 list.module list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL)
icor7 list.module list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL)
meedjum_blog7 list.module list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL)
mooc7 list.module list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL)

Returns the array of allowed values for a list field.

The strings are not safe for output. Keys and values of the array should be sanitized through field_filter_xss() before being displayed.

Parameters

$field: The field definition.

$instance: (optional) A field instance array. Defaults to NULL.

$entity_type: (optional) The type of entity; e.g. 'node' or 'user'. Defaults to NULL.

$entity: (optional) The entity object. Defaults to NULL.

Return value

The array of allowed values. Keys of the array are the raw stored values (number or text), values of the array are the display labels.

9 calls to list_allowed_values()
list_field_diff_view in sites/all/modules/ulmus/diff/includes/list.inc
Diff field callback for parsing list field comparative values.
list_field_formatter_view in modules/field/modules/list/list.module
Implements hook_field_formatter_view().
list_field_validate in modules/field/modules/list/list.module
Implements hook_field_validate().
list_options_list in modules/field/modules/list/list.module
Implements hook_options_list().
textformatter_list_field_create_list in sites/all/modules/ulmus/textformatter/textformatter.module
Create list for list fields.

... See full list

2 string references to 'list_allowed_values'
hook_field_update_field in modules/field/field.api.php
Act on a field being updated.
list_field_update_field in modules/field/modules/list/list.module
Implements hook_field_update_field().

File

modules/field/modules/list/list.module, line 235
Defines list field types that can be used with the Options module.

Code

function list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
  $allowed_values = &drupal_static(__FUNCTION__, array());

  if (!isset($allowed_values[$field['id']])) {
    $function = $field['settings']['allowed_values_function'];
    // If $cacheable is FALSE, then the allowed values are not statically
    // cached. See list_test_dynamic_values_callback() for an example of
    // generating dynamic and uncached values.
    $cacheable = TRUE;
    if (!empty($function) && function_exists($function)) {
      $values = $function($field, $instance, $entity_type, $entity, $cacheable);
    }
    else {
      $values = $field['settings']['allowed_values'];
    }

    if ($cacheable) {
      $allowed_values[$field['id']] = $values;
    }
    else {
      return $values;
    }
  }

  return $allowed_values[$field['id']];
}