public static function KeyValueFieldTypeTrait::generateSampleValue in Key value field 8
File
- src/
Plugin/ Field/ FieldType/ KeyValueFieldTypeTrait.php, line 102
Class
- KeyValueFieldTypeTrait
- Common traits for key value field types which inherit different field types.
Namespace
Drupal\key_value_field\Plugin\Field\FieldTypeCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
// Create a random data generator.
$random = new Random();
return [
// Add a random key.
'key' => $random
->word(mt_rand(1, $field_definition
->getSetting('key_max_length'))),
// Add a random description.
// @todo make sure the description is enabled before generating a value.
'description' => $random
->word(mt_rand(1, 255)),
] + parent::generateSampleValue($field_definition);
}