function FieldConfigInterface::setDefaultValueCallback

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/FieldConfigInterface.php \Drupal\Core\Field\FieldConfigInterface::setDefaultValueCallback()
  2. 8.9.x core/lib/Drupal/Core/Field/FieldConfigInterface.php \Drupal\Core\Field\FieldConfigInterface::setDefaultValueCallback()
  3. 11.x core/lib/Drupal/Core/Field/FieldConfigInterface.php \Drupal\Core\Field\FieldConfigInterface::setDefaultValueCallback()

Sets a custom default value callback.

If set, the callback overrides any set default value.

Parameters

string|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:

It should return the default value in the format accepted by the setDefaultValue() method.

Return value

$this

1 method overrides FieldConfigInterface::setDefaultValueCallback()
FieldConfigBase::setDefaultValueCallback in core/lib/Drupal/Core/Field/FieldConfigBase.php
Sets a custom default value callback.

File

core/lib/Drupal/Core/Field/FieldConfigInterface.php, line 151

Class

FieldConfigInterface
Defines an interface for configurable field definitions.

Namespace

Drupal\Core\Field

Code

public function setDefaultValueCallback($callback);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.