Commit c6a7ce5a authored by catch's avatar catch

Issue #3055516 by oknate, dasginganinja, Skymen, rgpublic, Wim Leers, seanB,...

Issue #3055516 by oknate, dasginganinja, Skymen, rgpublic, Wim Leers, seanB, phenaproxima, tstoeckler: Notice: Undefined index: target_bundles when new reference media field created
parent 9d9fd0ab
......@@ -146,7 +146,9 @@ protected function getAllowedMediaTypeIdsSorted() {
// Get the configured media types from the field storage.
$handler_settings = $this->getFieldSetting('handler_settings');
$allowed_media_type_ids = $handler_settings['target_bundles'];
// The target bundles will be blank when saving field storage settings,
// when first adding a media reference field.
$allowed_media_type_ids = isset($handler_settings['target_bundles']) ? $handler_settings['target_bundles'] : NULL;
// When there are no allowed media types, return the empty array.
if ($allowed_media_type_ids === []) {
......
......@@ -1582,4 +1582,36 @@ public function testWidgetOEmbed() {
$assert_session->elementExists('css', '.media-library-menu');
}
/**
* Tests field UI integration for media library widget.
*/
public function testFieldUiIntegration() {
$page = $this->getSession()->getPage();
$assert_session = $this->assertSession();
$this->drupalCreateContentType(['type' => 'article']);
$user = $this->drupalCreateUser([
'access administration pages',
'administer node fields',
'administer node form display',
]);
$this->drupalLogin($user);
$this->drupalGet('/admin/structure/types/manage/article/fields/add-field');
$page->selectFieldOption('new_storage_type', 'field_ui:entity_reference:media');
$this->assertTrue($assert_session->waitForField('label'));
$page->fillField('label', 'Shatner');
$this->assertTrue($assert_session->waitForText('field_shatner'));
$page->pressButton('Save and continue');
$page->pressButton('Save field settings');
$assert_session->pageTextNotContains('Undefined index: target_bundles');
$page->checkField('settings[handler_settings][target_bundles][type_one]');
$assert_session->assertWaitOnAjaxRequest();
$page->checkField('settings[handler_settings][target_bundles][type_two]');
$assert_session->assertWaitOnAjaxRequest();
$page->checkField('settings[handler_settings][target_bundles][type_three]');
$assert_session->assertWaitOnAjaxRequest();
$page->pressButton('Save settings');
$assert_session->pageTextContains('Saved Shatner configuration.');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment