function MediaLibraryWidgetTest::buildWidgetForm

Same name in other branches
  1. 8.9.x core/modules/media_library/tests/src/Kernel/MediaLibraryWidgetTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryWidgetTest::buildWidgetForm()
  2. 10 core/modules/media_library/tests/src/Kernel/MediaLibraryWidgetTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryWidgetTest::buildWidgetForm()
  3. 11.x core/modules/media_library/tests/src/Kernel/MediaLibraryWidgetTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryWidgetTest::buildWidgetForm()

Build the media library widget form.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to build the form for.

Return value

array A built form array of the media library widget.

2 calls to MediaLibraryWidgetTest::buildWidgetForm()
MediaLibraryWidgetTest::testRevisionableWidgetAccess in core/modules/media_library/tests/src/Kernel/MediaLibraryWidgetTest.php
Test the media library widget access with a revisionable entity type.
MediaLibraryWidgetTest::testWidgetAccess in core/modules/media_library/tests/src/Kernel/MediaLibraryWidgetTest.php
Test the media library widget access.

File

core/modules/media_library/tests/src/Kernel/MediaLibraryWidgetTest.php, line 158

Class

MediaLibraryWidgetTest
Tests the media library widget.

Namespace

Drupal\Tests\media_library\Kernel

Code

protected function buildWidgetForm($entity) {
    $form = [
        '#parents' => [],
    ];
    return $this->container
        ->get('plugin.manager.field.widget')
        ->createInstance('media_library_widget', [
        'field_definition' => $this->baseField,
        'settings' => [],
        'third_party_settings' => [],
    ])
        ->formElement($entity->media, 0, [
        '#description' => '',
    ], $form, new FormState());
}

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