function field_attach_submit

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

Parameters

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

Drupal\Core\Entity\EntityInterface $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_method() for details.

Related topics

5 calls to field_attach_submit()
EntityFormControllerNG::buildEntity in drupal/core/lib/Drupal/Core/Entity/EntityFormControllerNG.php
Overrides EntityFormController::buildEntity().
entity_form_submit_build_entity in drupal/core/includes/entity.inc
Copies submitted values to entity properties for simple entity forms.
FieldAttachOtherTest::testFieldAttachSubmit in drupal/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
Test field_attach_submit().
field_test_entity_nested_form_submit in drupal/core/modules/field/tests/modules/field_test/field_test.entity.inc
Submit handler for field_test_entity_nested_form().
field_test_entity_nested_form_validate in drupal/core/modules/field/tests/modules/field_test/field_test.entity.inc
Validate handler for field_test_entity_nested_form().

File

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

Code

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

  // Extract field values from submitted values.
  field_invoke_method('submit', _field_invoke_widget_target(), $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);
  }
}