function IntegerItem::generateSampleValue
Same name in other branches
- 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php \Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem::generateSampleValue()
- 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php \Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem::generateSampleValue()
- 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php \Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem::generateSampleValue()
Overrides FieldItemBase::generateSampleValue
File
-
core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ IntegerItem.php, line 105
Class
- IntegerItem
- Defines the 'integer' field type.
Namespace
Drupal\Core\Field\Plugin\Field\FieldTypeCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
$min = $field_definition->getSetting('min') ?: 0;
$max = $field_definition->getSetting('max') ?: 999;
$values['value'] = mt_rand($min, $max);
return $values;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.