function hook_field_load

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 field.api.php hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
cle7 field.api.php hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
elmsmedia7 field.api.php hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
icor7 field.api.php hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
meedjum_blog7 field.api.php hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)
mooc7 field.api.php hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)

Define custom load behavior for this module's field types.

Unlike most other field hooks, this hook operates on multiple entities. The $entities, $instances and $items parameters are arrays keyed by entity ID. For performance reasons, information for all available entity should be loaded in a single query where possible.

Note that the changes made to the field values get cached by the field cache for subsequent loads. You should never use this hook to load fieldable entities, since this is likely to cause infinite recursions when hook_field_load() is run on those as well. Use hook_field_formatter_prepare_view() instead.

Make changes or additions to field values by altering the $items parameter by reference. There is no return value.

Parameters

$entity_type: The type of $entity.

$entities: Array of entities being loaded, keyed by entity ID.

$field: The field structure for the operation.

$instances: Array of instance structures for $field for each entity, keyed by entity ID.

$langcode: The language code associated with $items.

$items: Array of field values already loaded for the entities, keyed by entity ID. Store your changes in this parameter (passed by reference).

$age: FIELD_LOAD_CURRENT to load the most recent revision for all fields, or FIELD_LOAD_REVISION to load the version indicated by each entity.

Related topics

9 functions implement hook_field_load()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

date_field_load in sites/all/modules/ulmus/date/date.field.inc
Implements hook_field_load().
entityreference_field_load in sites/all/modules/ulmus/entityreference/entityreference.module
Implements hook_field_load().
features_field_load in sites/all/modules/ulmus/features/includes/features.field.inc
Load a field's configuration and instance configuration by an entity_type-bundle-field_name identifier.
field_test_field_load in modules/field/tests/field_test.field.inc
Implements hook_field_load().
file_field_load in modules/file/file.field.inc
Implements hook_field_load().

... See full list

2 invocations of hook_field_load()
field_attach_load in modules/field/field.attach.inc
Loads fields for the current revisions of a group of entities.
node_preview in modules/node/node.pages.inc
Generates a node preview.

File

modules/field/field.api.php, line 308

Code

function hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
  // Sample code from text.module: precompute sanitized strings so they are
  // stored in the field cache.
  foreach ($entities as $id => $entity) {
    foreach ($items[$id] as $delta => $item) {
      // Only process items with a cacheable format, the rest will be handled
      // by formatters if needed.
      if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) {
        $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : '';
        if ($field['type'] == 'text_with_summary') {
          $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
        }
      }
    }
  }
}