function hook_field_attach_submit

7.x field.api.php hook_field_attach_submit($entity_type, $entity, $form, &$form_state)

Act on field_attach_submit().

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

Parameters

$entity_type: The type of $entity; for example, 'node' or 'user'.

$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 where 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_submit()
field_attach_submit in drupal/modules/field/field.attach.inc
Perform necessary operations on field data submitted by a form.

File

drupal/modules/field/field.api.php, line 1372
Hooks provided by the Field module.

Code

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