function field_attach_submit

Perform necessary operations on field data submitted by a form.

Currently, this accounts for drag-and-drop reordering of field values, and filtering of empty values.


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

$entity: The entity being submitted. The 'bundle', 'id' and (if applicable) 'revision' keys should be present. The actual field values will be read from $form_state['values'].

$form: The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.

$form_state: An associative array containing the current state of the form.

array $options: An associative array of additional options. See _field_invoke() for details.

Related topics

3 calls to field_attach_submit()
entity_form_submit_build_entity in drupal/includes/
Copies submitted values to entity properties for simple entity forms.
FieldAttachOtherTestCase::testFieldAttachSubmit in drupal/modules/field/tests/field.test
Test field_attach_submit().
field_test_entity_nested_form_submit in drupal/modules/field/tests/
Submit handler for field_test_entity_nested_form().


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


function field_attach_submit($entity_type, $entity, $form, &$form_state, $options = array()) {

  // Validate $options since this is a new parameter added after Drupal 7 was
  // released.
  $options = is_array($options) ? $options : array();

  // Extract field values from submitted values.
  _field_invoke_default('extract_form_values', $entity_type, $entity, $form, $form_state, $options);
  _field_invoke_default('submit', $entity_type, $entity, $form, $form_state, $options);

  // Let other modules act on submitting the entity.
  // Avoid module_invoke_all() to let $form_state be taken by reference.
  foreach (module_implements('field_attach_submit') as $module) {
    $function = $module . '_field_attach_submit';
    $function($entity_type, $entity, $form, $form_state);