diff --git a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php index d59906a..f34108c 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php @@ -89,7 +89,8 @@ class FieldInstance extends ConfigEntityBase implements \ArrayAccess { * This will be used as the title of Form API elements for the field in entity * edit forms, or as the label for the field values in displayed entities. * - * If not specified, this defaults to the field_name. + * If not specified, this defaults to the field_name (mostly useful for field + * instances created in tests). * * @var string */ @@ -267,9 +268,9 @@ public function __construct(array $values, $entity_type = 'field_instance') { } // Set field label to field name if no value has been set. - if ($this->label == NULL) { - $this->label = $values['field_name']; - } + $values += array( + 'label' => $values['field_name'], + ); parent::__construct($values, $entity_type); }