You are here

public static function KeyValueFieldTypeTrait::propertyDefinitions in Key value field 8

File

src/Plugin/Field/FieldType/KeyValueFieldTypeTrait.php, line 47

Class

KeyValueFieldTypeTrait
Common traits for key value field types which inherit different field types.

Namespace

Drupal\key_value_field\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  return [
    // Add the property definition for the key field.
    'key' => DataDefinition::create('string')
      ->setLabel(new TranslatableMarkup('Key'))
      ->setRequired(TRUE),
    // Add the property definition for the description field.
    'description' => DataDefinition::create('string')
      ->setLabel(new TranslatableMarkup('Description'))
      ->setRequired(FALSE),
  ] + parent::propertyDefinitions($field_definition);
}