You are here

public function FileWidget::extractFormValues in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php \Drupal\file\Plugin\Field\FieldWidget\FileWidget::extractFormValues()
  2. 9 core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php \Drupal\file\Plugin\Field\FieldWidget\FileWidget::extractFormValues()

Extracts field values from submitted form values.

Parameters

\Drupal\Core\Field\FieldItemListInterface $items: The field values. This parameter is altered by reference to receive the incoming form values.

array $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.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Overrides WidgetBase::extractFormValues

File

core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php, line 296

Class

FileWidget
Plugin implementation of the 'file_generic' widget.

Namespace

Drupal\file\Plugin\Field\FieldWidget

Code

public function extractFormValues(FieldItemListInterface $items, array $form, FormStateInterface $form_state) {
  parent::extractFormValues($items, $form, $form_state);

  // 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);
  $field_state['items'] = $items
    ->getValue();
  static::setWidgetState($form['#parents'], $field_name, $form_state, $field_state);
}