function hook_field_insert

×

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_insert($entity_type, $entity, $field, $instance, $langcode, &$items)
cle7 field.api.php hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items)
elmsmedia7 field.api.php hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items)
icor7 field.api.php hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items)
meedjum_blog7 field.api.php hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items)
mooc7 field.api.php hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items)

Define custom insert behavior for this module's field data.

This hook is invoked from field_attach_insert() on the module that defines a field, during the process of inserting an entity object (node, taxonomy term, etc.). It is invoked just before the data for this field on the particular entity object is inserted into field storage. Only field modules that are storing or tracking information outside the standard field storage mechanism need to implement this hook.

Parameters

$entity_type: The type of $entity.

$entity: The entity for the operation.

$field: The field structure for the operation.

$instance: The instance structure for $field on $entity's bundle.

$langcode: The language associated with $items.

$items: $entity->{$field['field_name']}[$langcode], or an empty array if unset.

See also

hook_field_update()

hook_field_delete()

Related topics

9 functions implement hook_field_insert()

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

date_field_insert in sites/all/modules/ulmus/date/date.field.inc
Implements hook_field_insert().
date_repeat_field_date_field_insert in sites/all/modules/ulmus/date/date_repeat_field/date_repeat_field.devel_generate.inc
Implements hook_date_field_insert().
entityreference_field_insert in sites/all/modules/ulmus/entityreference/entityreference.module
Implements hook_field_insert().
field_collection_field_insert in sites/all/modules/ulmus/field_collection/field_collection.module
Implements hook_field_insert().
field_test_field_insert in modules/field/tests/field_test.field.inc
Implements hook_field_insert().

... See full list

3 invocations of hook_field_insert()
EntityAPIController::save in sites/all/modules/ulmus/entity/includes/entity.controller.inc
Implements EntityAPIControllerInterface.
field_attach_insert in modules/field/field.attach.inc
Save field data for a new entity.
user_save in modules/user/user.module
Save changes to a user account or add a new user.

File

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

Code

function hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) {
    $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created',));
    foreach ($items as $item) {
      $query->values(array(
        'nid' => $entity->nid,
        'tid' => $item['tid'],
        'sticky' => $entity->sticky,
        'created' => $entity->created,
      ));
    }
    $query->execute();
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.