function UuidItem::applyDefaultValue

Overrides Map::applyDefaultValue

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php, line 36

Class

UuidItem
Defines the 'uuid' entity field type.

Namespace

Drupal\Core\Field\Plugin\Field\FieldType

Code

public function applyDefaultValue($notify = TRUE) {
  // Default to one field item with a generated UUID.
  $uuid = \Drupal::service('uuid');
  $this->setValue([
    'value' => $uuid->generate(),
  ], $notify);
  return $this;
}

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