diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index b3bfa9f..232783f 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -295,11 +295,12 @@ public function massageFormValues(array $values, array $form, FormStateInterface } } - // Remove stale reference to 'items' stored during upload. + // Update reference to 'items' stored during upload to take into account + // changes to values like 'alt' etc. // @see \Drupal\file\Plugin\Field\FieldWidget\FileWidget::submit() $field_name = $this->fieldDefinition->getName(); $field_state = static::getWidgetState($form['#parents'], $field_name, $form_state); - unset($field_state['items']); + $field_state['items'] = $new_values; static::setWidgetState($form['#parents'], $field_name, $form_state, $field_state); return $new_values;