function MediaLibraryWidget::form
Same name in other branches
- 8.9.x core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php \Drupal\media_library\Plugin\Field\FieldWidget\MediaLibraryWidget::form()
- 10 core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php \Drupal\media_library\Plugin\Field\FieldWidget\MediaLibraryWidget::form()
- 11.x core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php \Drupal\media_library\Plugin\Field\FieldWidget\MediaLibraryWidget::form()
Overrides WidgetBase::form
File
-
core/
modules/ media_library/ src/ Plugin/ Field/ FieldWidget/ MediaLibraryWidget.php, line 280
Class
- MediaLibraryWidget
- Plugin implementation of the 'media_library_widget' widget.
Namespace
Drupal\media_library\Plugin\Field\FieldWidgetCode
public function form(FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta = NULL) {
// Load the items for form rebuilds from the field state.
$field_state = static::getWidgetState($form['#parents'], $this->fieldDefinition
->getName(), $form_state);
if (isset($field_state['items'])) {
usort($field_state['items'], [
SortArray::class,
'sortByWeightElement',
]);
$items->setValue($field_state['items']);
}
return parent::form($items, $form, $form_state, $get_delta);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.