public function FieldDefinition::setDefaultValueCallback in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Field/FieldDefinition.php \Drupal\Core\Field\FieldDefinition::setDefaultValueCallback()
- 9 core/lib/Drupal/Core/Field/FieldDefinition.php \Drupal\Core\Field\FieldDefinition::setDefaultValueCallback()
Set the default value callback for the field.
Parameters
string $callback: The default value callback.
Return value
$this
File
- core/
lib/ Drupal/ Core/ Field/ FieldDefinition.php, line 178
Class
- FieldDefinition
- A class for defining entity field definitions.
Namespace
Drupal\Core\FieldCode
public function setDefaultValueCallback($callback) {
if (isset($callback) && !is_string($callback)) {
throw new \InvalidArgumentException('Default value callback must be a string, like "function_name" or "ClassName::methodName"');
}
$this->definition['default_value_callback'] = $callback;
return $this;
}