function field_attach_update


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/
cis7 field_attach_update($entity_type, $entity)
cle7 field_attach_update($entity_type, $entity)
elmsmedia7 field_attach_update($entity_type, $entity)
icor7 field_attach_update($entity_type, $entity)
meedjum_blog7 field_attach_update($entity_type, $entity)
mooc7 field_attach_update($entity_type, $entity)

Save field data for an existing entity.

When calling this function outside an entity save operation be sure to clear caches for the entity:



$entity_type: The type of $entity; e.g. 'node' or 'user'.

$entity: The entity with fields to save.

Related topics

7 calls to field_attach_update()
comment_save in modules/comment/comment.module
Accepts a submission of new or changed comment content.
EntityAPIController::save in sites/all/modules/ulmus/entity/includes/
Implements EntityAPIControllerInterface.
filefield_paths_entity_update in sites/all/modules/ulmus/filefield_paths/filefield_paths.module
Implements hook_entity_update().
file_entity_file_update in sites/all/modules/ulmus/file_entity/
Implements hook_file_update().
taxonomy_term_save in modules/taxonomy/taxonomy.module
Saves a term object to the database.

... See full list


modules/field/, line 990
Field attach API, allowing entities (nodes, users, ...) to be 'fieldable'.


function field_attach_update($entity_type, $entity) {
  _field_invoke('update', $entity_type, $entity);

  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);

  // Let any module update field data before the storage engine, accumulating
  // saved fields along the way.
  $skip_fields = array();
  foreach (module_implements('field_storage_pre_update') as $module) {
    $function = $module . '_field_storage_pre_update';
    $function($entity_type, $entity, $skip_fields);

  // Collect the storage backends used by the remaining fields in the entities.
  $storages = array();
  foreach (field_info_instances($entity_type, $bundle) as $instance) {
    $field = field_info_field_by_id($instance['field_id']);
    $field_id = $field['id'];
    $field_name = $field['field_name'];
    // Leave the field untouched if $entity comes with no $field_name property,
    // but empty the field if it comes as a NULL value or an empty array.
    // Function property_exists() is slower, so we catch the more frequent
    // cases where it's an empty array with the faster isset().
    if (isset($entity->$field_name) || property_exists($entity, $field_name)) {
      // Collect the storage backend if the field has not been written yet.
      if (!isset($skip_fields[$field_id])) {
        $storages[$field['storage']['type']][$field_id] = $field_id;

  // Field storage backends save any remaining unsaved fields.
  foreach ($storages as $storage => $fields) {
    $storage_info = field_info_storage_types($storage);
    module_invoke($storage_info['module'], 'field_storage_write', $entity_type, $entity, FIELD_STORAGE_UPDATE, $fields);

  // Let other modules act on updating the entity.
  module_invoke_all('field_attach_update', $entity_type, $entity);

  $entity_info = entity_get_info($entity_type);
  if ($entity_info['field cache']) {
    cache_clear_all("field:$entity_type:$id", 'cache_field');