Commit 7871cc00 authored by xjm's avatar xjm

Issue #2937889 by larowlan, Sam152: Regression: LinkWidget no longer supports...

Issue #2937889 by larowlan, Sam152: Regression: LinkWidget no longer supports base fields with optional title
parent 8a19bec6
...@@ -227,7 +227,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen ...@@ -227,7 +227,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
if (!$element['title']['#required']) { if (!$element['title']['#required']) {
// Make title required on the front-end when URI filled-in. // 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 = $element['#field_parents'];
$parents[] = $field_name; $parents[] = $field_name;
......
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
<?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 { ...@@ -24,7 +24,12 @@ class LinkFieldTest extends BrowserTestBase {
* *
* @var array * @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. * A field to use in this test class.
......
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