You are here

public function AddFormBase::preRenderAddedMedia in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::preRenderAddedMedia()
  2. 10 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::preRenderAddedMedia()

Converts the set of newly added media into an item list for rendering.

Parameters

array $element: The render element to transform.

Return value

array The transformed render element.

File

core/modules/media_library/src/Form/AddFormBase.php, line 361

Class

AddFormBase
Provides a base class for creating media items from within the media library.

Namespace

Drupal\media_library\Form

Code

public function preRenderAddedMedia(array $element) {

  // Transform the element into an item list for rendering.
  $element['#theme'] = 'item_list__media_library_add_form_media_list';
  $element['#list_type'] = 'ul';
  foreach (Element::children($element) as $delta) {
    $element['#items'][$delta] = $element[$delta];
    unset($element[$delta]);
  }
  return $element;
}