function hook_field_attach_extract_form_values

Act on field_attach_extract_form_values().

This hook is invoked after the field module has performed the operation.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which an edit form is being submitted. The incoming form values have been extracted as field values of the $entity object.

$form: The form structure field elements are attached to. This might be a full form structure, or a sub-part of a larger form. The $form['#parents'] property can be used to identify the corresponding part of $form_state['values'].

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

Related topics

1 invocation of hook_field_attach_extract_form_values()
field_attach_extract_form_values in drupal/core/modules/field/field.attach.inc
Populates an entity object with values from a form submission.

File

drupal/core/modules/field/field.api.php, line 925

Code

function hook_field_attach_extract_form_values(\Drupal\Core\Entity\EntityInterface $entity, $form, &$form_state) {

  // Sample case of an 'Empty the field' checkbox added on the form, allowing
  // a given field to be emptied.
  $values = NestedArray::getValue($form_state['values'], $form['#parents']);
  if (!empty($values['empty_field_foo'])) {
    unset($entity->field_foo);
  }
}