public FieldItemList::generateSampleItems($count = 1)
Populates a specified number of field items with valid sample data.
Parameters
int $count: The number of items to create.
Overrides FieldItemListInterface::generateSampleItems
File
- core/lib/Drupal/Core/Field/FieldItemList.php, line 260
Class
- FieldItemList
- Represents an entity field; that is, a list of field item objects.
Namespace
Drupal\Core\Field
Code
1 2 3 4 5 6 7 8 | public function generateSampleItems( $count = 1) { $field_definition = $this ->getFieldDefinition(); $field_type_class = \Drupal::service( 'plugin.manager.field.field_type' )->getPluginClass( $field_definition -> getType ()); for ( $delta = 0; $delta < $count ; $delta ++) { $values [ $delta ] = $field_type_class ::generateSampleValue( $field_definition ); } $this ->setValue( $values ); } |
Please login to continue.