function hook_field_insert

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.


$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



Related topics

3 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.

field_test_field_insert in modules/field/tests/
Implements hook_field_insert().
file_field_insert in modules/file/
Implements hook_field_insert().
image_field_insert in modules/image/
Implements hook_field_insert().
1 invocation of hook_field_insert()
field_attach_insert in modules/field/
Save field data for a new entity.


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


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(
        foreach ($items as $item) {
                'nid' => $entity->nid,
                'tid' => $item['tid'],
                'sticky' => $entity->sticky,
                'created' => $entity->created,

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.