Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FieldDefinitionInterface.php

function FieldDefinitionInterface::getDefaultValue

Returns the default value for the field in a newly created entity.

This method computes the runtime default value for a field in a given entity. To access the raw properties assigned to the field definition, ::getDefaultValueLiteral() or ::getDefaultValueCallback() should be used instead.

Parameters

\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity for which the default value is generated.

Return value

array The default value for the field, as a numerically indexed array of items, each item being a property/value array (array() for no default value).

See also

FieldDefinitionInterface::getDefaultValueLiteral()

FieldDefinitionInterface::getDefaultValueCallback()

3 methods override FieldDefinitionInterface::getDefaultValue()
BaseFieldDefinition::getDefaultValue in core/lib/Drupal/Core/Field/BaseFieldDefinition.php
Returns the default value for the field in a newly created entity.
FieldConfigBase::getDefaultValue in core/lib/Drupal/Core/Field/FieldConfigBase.php
Returns the default value for the field in a newly created entity.
FieldDefinition::getDefaultValue in core/lib/Drupal/Core/Field/FieldDefinition.php
Returns the default value for the field in a newly created entity.

File

core/lib/Drupal/Core/Field/FieldDefinitionInterface.php, line 228

Class

FieldDefinitionInterface
Defines an interface for entity field definitions.

Namespace

Drupal\Core\Field

Code

public function getDefaultValue(FieldableEntityInterface $entity);

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal