Unverified Commit bbb2de82 authored by larowlan's avatar larowlan

Issue #3122051 by phenaproxima, andrewmacpherson, Kristen Pol: Name field is...

Issue #3122051 by phenaproxima, andrewmacpherson, Kristen Pol: Name field is always shown on media library form display when adding a new remote video media type
parent c6aa9bc1
......@@ -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' => [
......
......@@ -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();
......
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