function ListStringItem::propertyDefinitions

Same name and namespace in other branches
  1. 8.9.x core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php \Drupal\options\Plugin\Field\FieldType\ListStringItem::propertyDefinitions()
  2. 10 core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php \Drupal\options\Plugin\Field\FieldType\ListStringItem::propertyDefinitions()
  3. 11.x core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php \Drupal\options\Plugin\Field\FieldType\ListStringItem::propertyDefinitions()

Defines field item properties.

Properties that are required to constitute a valid, non-empty item should be denoted with \Drupal\Core\TypedData\DataDefinition::setRequired().

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.

Overrides FieldItemInterface::propertyDefinitions

File

core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php, line 27

Class

ListStringItem
Plugin implementation of the 'list_string' field type.

Namespace

Drupal\options\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $properties['value'] = DataDefinition::create('string')->setLabel(new TranslatableMarkup('Text value'))
        ->addConstraint('Length', [
        'max' => 255,
    ])
        ->setRequired(TRUE);
    return $properties;
}

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