public function FieldDefinitionInterface::getDefaultValue in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Field/FieldDefinitionInterface.php \Drupal\Core\Field\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\FieldCode
public function getDefaultValue(FieldableEntityInterface $entity);