diff --git a/core/lib/Drupal/Core/Field/FieldDefinition.php b/core/lib/Drupal/Core/Field/FieldDefinition.php index 1c0777dda4bff28e8f8a34dabb2745c838162591..a0576f65143899d34d3c8402a6f800e5e06c1d34 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinition.php +++ b/core/lib/Drupal/Core/Field/FieldDefinition.php @@ -380,7 +380,7 @@ public function isDisplayConfigurable($display_context) { */ public function getDefaultValue(ContentEntityInterface $entity) { // Allow custom default values function. - if (isset($this->definition['default_value_callback'])) { + if (!empty($this->definition['default_value_callback'])) { $value = call_user_func($this->definition['default_value_callback'], $entity, $this); } else { @@ -396,9 +396,10 @@ public function getDefaultValue(ContentEntityInterface $entity) { * * If set, the callback overrides any set default value. * - * @param string|array $callback - * The callback to invoke for getting the default value. The callback will - * be invoked with the following arguments: + * @param callable|null $callback + * The callback to invoke for getting the default value (pass NULL to unset + * a previously set callback). The callback will be invoked with the + * following arguments: * - \Drupal\Core\Entity\ContentEntityInterface $entity * The entity being created. * - \Drupal\Core\Field\FieldDefinitionInterface $definition