function AddFormBase::preRenderAddedMedia

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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 358

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.