summaryrefslogtreecommitdiff
path: root/modules/field/field.default.inc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/field/field.default.inc')
-rw-r--r--modules/field/field.default.inc33
1 files changed, 28 insertions, 5 deletions
diff --git a/modules/field/field.default.inc b/modules/field/field.default.inc
index 5af888967..79e0b937b 100644
--- a/modules/field/field.default.inc
+++ b/modules/field/field.default.inc
@@ -11,13 +11,36 @@
* the corresponding field_attach_[operation]() function.
*/
+/**
+ * Extracts field values from submitted form values.
+ *
+ * @param $entity_type
+ * The type of $entity.
+ * @param $entity
+ * The entity for the operation.
+ * @param $field
+ * The field structure for the operation.
+ * @param $instance
+ * The instance structure for $field on $entity's bundle.
+ * @param $langcode
+ * The language associated to $items.
+ * @param $items
+ * The field values. This parameter is altered by reference to receive the
+ * incoming form values.
+ * @param $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.
+ * @param $form_state
+ * The form state.
+ */
function field_default_extract_form_values($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) {
- $field_name = $field['field_name'];
-
- if (isset($form_state['values'][$field_name][$langcode])) {
- $items = $form_state['values'][$field_name][$langcode];
+ $path = array_merge($form['#parents'], array($field['field_name'], $langcode));
+ $key_exists = NULL;
+ $values = drupal_array_get_nested_value($form_state['values'], $path, $key_exists);
+ if ($key_exists) {
// Remove the 'value' of the 'add more' button.
- unset($items['add_more']);
+ unset($values['add_more']);
+ $items = $values;
}
}