public function MediaLibraryWidget::extractFormValues in Drupal 10
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/ media_library/ src/ Plugin/ Field/ FieldWidget/ MediaLibraryWidget.php, line 292
Class
- MediaLibraryWidget
- Plugin implementation of the 'media_library_widget' widget.
Namespace
Drupal\media_library\Plugin\Field\FieldWidgetCode
public function extractFormValues(FieldItemListInterface $items, array $form, FormStateInterface $form_state) {
parent::extractFormValues($items, $form, $form_state);
// Update reference to 'items' stored during add or remove to take into
// account changes to values like 'weight' etc.
// @see Drupal\media_library\Plugin\Field\FieldWidget\MediaLibraryWidget::addItems
// @see Drupal\media_library\Plugin\Field\FieldWidget\MediaLibraryWidget::removeItem
$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);
}