Skip to content
Snippets Groups Projects
Unverified Commit 2c979f05 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3208849 by yogeshmpawar, cilefen, phenaproxima, mohit_aghera, larowlan,...

Issue #3208849 by yogeshmpawar, cilefen, phenaproxima, mohit_aghera, larowlan, danflanagan8: OEmbedWidget does not display the field's help text, only its own message
parent 320c5ff4
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
$source = $items->getEntity()->getSource();
$message = $this->t('You can link to media from the following services: @providers', ['@providers' => implode(', ', $source->getProviders())]);
if (!empty($element['#value']['#description'])) {
if (!empty($element['value']['#description'])) {
$element['value']['#description'] = [
'#theme' => 'item_list',
'#items' => [$element['value']['#description'], $message],
......
<?php
namespace Drupal\Tests\media\Functional\FieldWidget;
use Drupal\field\Entity\FieldConfig;
use Drupal\Tests\media\Functional\MediaFunctionalTestBase;
/**
* @covers \Drupal\media\Plugin\Field\FieldWidget\OEmbedWidget
*
* @group media
*/
class OEmbedFieldWidgetTest extends MediaFunctionalTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests that the oEmbed field widget shows the configured help text.
*/
public function testFieldWidgetHelpText() {
$account = $this->drupalCreateUser(['create media']);
$this->drupalLogin($account);
$media_type = $this->createMediaType('oembed:video');
$source_field = $media_type->getSource()
->getSourceFieldDefinition($media_type)
->getName();
/** @var \Drupal\field\Entity\FieldConfig $field */
$field = FieldConfig::loadByName('media', $media_type->id(), $source_field);
$field->setDescription('This is help text for oEmbed field.')
->save();
$this->drupalGet('media/add/' . $media_type->id());
$assert_session = $this->assertSession();
$assert_session->pageTextContains('This is help text for oEmbed field.');
$assert_session->pageTextContains('You can link to media from the following services: YouTube, Vimeo');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment