Issue #2937889 by larowlan, Sam152: Regression: LinkWidget no longer supports base fields with optional title
parent
8a19bec6e7
commit
7871cc00ee
|
@ -227,7 +227,7 @@ class LinkWidget extends WidgetBase {
|
|||
|
||||
if (!$element['title']['#required']) {
|
||||
// Make title required on the front-end when URI filled-in.
|
||||
$field_name = $this->fieldDefinition->get('field_name');
|
||||
$field_name = $this->fieldDefinition->getName();
|
||||
|
||||
$parents = $element['#field_parents'];
|
||||
$parents[] = $field_name;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
name: Link test base field
|
||||
description: Tests link field as an optional base field
|
||||
type: module
|
||||
core: 8.x
|
||||
hidden: true
|
||||
dependencies:
|
||||
- link
|
||||
- entity_test
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains main module functions.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\link\LinkItemInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_entity_base_field_info().
|
||||
*/
|
||||
function link_test_base_field_entity_base_field_info(EntityTypeInterface $entity_type) {
|
||||
$fields = [];
|
||||
if ($entity_type->id() === 'entity_test') {
|
||||
$fields['links'] = BaseFieldDefinition::create('link')
|
||||
->setLabel(t('Links'))
|
||||
->setRevisionable(TRUE)
|
||||
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
|
||||
->setDescription(t('Add links to the entity.'))
|
||||
->setRequired(FALSE)
|
||||
->setSettings([
|
||||
'link_type' => LinkItemInterface::LINK_GENERIC,
|
||||
'title' => DRUPAL_REQUIRED,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'link_default',
|
||||
'weight' => 49,
|
||||
]);
|
||||
}
|
||||
return $fields;
|
||||
}
|
|
@ -24,7 +24,12 @@ class LinkFieldTest extends BrowserTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['entity_test', 'link', 'node'];
|
||||
public static $modules = [
|
||||
'entity_test',
|
||||
'link',
|
||||
'node',
|
||||
'link_test_base_field',
|
||||
];
|
||||
|
||||
/**
|
||||
* A field to use in this test class.
|
||||
|
|
Loading…
Reference in New Issue