1 field.attach.inc | field_attach_submit($entity_type, $entity, $form, &$form_state, $options = array()) |
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.
Parameters
$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
File
- core/
modules/ field/ field.attach.inc, line 840 - Field attach API, allowing entities (nodes, users, ...) to be 'fieldable'.
Code
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);
}
}