public static function JSONItem::generateSampleValue in JSON Field 8
Generates placeholder field values.
Useful when populating site with placeholder content during site building or profiling.
Parameters
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
Return value
array An associative array of values.
Overrides FieldItemBase::generateSampleValue
File
- src/
Plugin/ Field/ FieldType/ JSONItem.php, line 161
Class
- JSONItem
- Plugin implementation of the 'JSON' field type.
Namespace
Drupal\json_field\Plugin\Field\FieldTypeCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
$random = new Random();
$values['value'] = '{"foo": "' . $random
->word(mt_rand(1, 2000)) . '""}';
return $values;
}