diff -u b/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php --- b/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -365,18 +365,21 @@ $parents = $parent_element['#field_parents']; $field_state = static::getWidgetState($parents, $field_name, $form_state); $user_input = $form_state->getUserInput(); - $field_values = []; - foreach ($user_input[$field_name] as $key => $input) { - if (is_numeric($key) && $key >= $delta) { - if ((int) $key === $delta) { - continue; + $field_input = NestedArray::getValue($user_input, $parent_element['#parents'], $exists); + if ($exists) { + $field_values = []; + foreach ($field_input as $key => $input) { + if (is_numeric($key) && $key >= $delta) { + if ((int) $key === $delta) { + continue; + } + --$key; } - --$key; + $field_values[$key] = $input; } - $field_values[$key] = $input; + NestedArray::setValue($user_input, $parent_element['#parents'], $field_values); + $form_state->setUserInput($user_input); } - $user_input[$field_name] = $field_values; - $form_state->setUserInput($user_input); unset($parent_element[$delta]); NestedArray::setValue($form, $array_parents, $parent_element);