Skip to content

Commit

Permalink
Issue #3122051 by phenaproxima, andrewmacpherson, Kristen Pol: Name f…
Browse files Browse the repository at this point in the history
…ield is always shown on media library form display when adding a new remote video media type

(cherry picked from commit bbb2de82426fbe48d1baa9deb421beae68d0814d)
  • Loading branch information
larowlan committed Jul 23, 2020
1 parent ef2d814 commit 79cb062
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions modules/media_library/media_library.module
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,7 @@ function _media_library_configure_form_display(MediaTypeInterface $type) {
$display->removeComponent($name);
}
// Expose the name field when it is not mapped.
$field_map = $type->getFieldMap();
if (empty($field_map['name'])) {
if (!in_array('name', $type->getFieldMap(), TRUE)) {
$display->setComponent('name', [
'type' => 'string_textfield',
'settings' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ public function testDisplayModes() {
$this->assertFormDisplay($type_eight_id, FALSE, TRUE);
$this->assertViewDisplay($type_eight_id, 'medium');

// Create an oEmbed media type with a mapped name field in the UI.
$type_id = 'pinto_bean';
$edit = [
'label' => $type_id,
'id' => $type_id,
'source' => 'oembed:video',
];
$this->drupalPostForm('admin/structure/media/add', $edit, 'Save');
$edit = [
'field_map[title]' => 'name',
];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertSession()->pageTextContains("Media Library form and view displays have been created for the $type_id media type.");
$this->assertFormDisplay($type_id, FALSE, FALSE);
$this->assertViewDisplay($type_id, 'medium');

// Delete a form and view display.
EntityFormDisplay::load('media.type_one.media_library')->delete();
EntityViewDisplay::load('media.type_one.media_library')->delete();
Expand Down

0 comments on commit 79cb062

Please sign in to comment.