diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-11-20 19:57:01 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-11-20 19:57:01 +0000 |
commit | 682481a259af5208fd59d747002eb19cf245875f (patch) | |
tree | 6bde6f899d38c264f18990f100408028a6fd30f3 /modules/file | |
parent | 3b8e8ff6eb28261f3d3b0cb5a9edd00bd8fbdb1e (diff) | |
download | brdo-682481a259af5208fd59d747002eb19cf245875f.tar.gz brdo-682481a259af5208fd59d747002eb19cf245875f.tar.bz2 |
#942310 by an.droid, yched, fago, sun: Fixed Field form cannot be attached more than once
Diffstat (limited to 'modules/file')
-rw-r--r-- | modules/file/file.field.inc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc index d4e98fa5d..d09cd5c47 100644 --- a/modules/file/file.field.inc +++ b/modules/file/file.field.inc @@ -450,9 +450,14 @@ function file_field_widget_form(&$form, &$form_state, $field, $instance, $langco // Retrieve any values set in $form_state, as will be the case during AJAX // rebuilds of this form. - if (isset($form_state['values'][$field['field_name']][$langcode])) { - $items = $form_state['values'][$field['field_name']][$langcode]; - unset($form_state['values'][$field['field_name']][$langcode]); + if (isset($form_state['values'])) { + $path = array_merge($element['#field_parents'], array($field['field_name'], $langcode)); + $path_exists = FALSE; + $values = drupal_array_get_nested_value($form_state['values'], $path, $path_exists); + if ($path_exists) { + $items = $values; + drupal_array_set_nested_value($form_state['values'], $path, NULL); + } } foreach ($items as $delta => $item) { @@ -748,8 +753,8 @@ function file_field_widget_submit($form, &$form_state) { // to avoid a mismatch between old and new deltas. The rebuilt elements will // have #default_value set appropriately for the current state of the field, // so nothing is lost in doing this. - list($field_name, $langcode) = $form_state['triggering_element']['#parents']; - unset($form_state['input'][$field_name][$langcode]); + $parents = array_slice($form_state['triggering_element']['#parents'], 0, -2); + drupal_array_set_nested_value($form_state['input'], $parents, NULL); } /** |